This is my markup of GridView.
<Columns>
<asp:TemplateField HeaderText="Customer Name">
<ItemTemplate>
<asp:Label ID="lblname" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Customer.Name")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PickUpPoint">
<ItemTemplate>
<asp:Label ID="lblPickUpPoint" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Pickuppoint")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
I have a button which stores the values in the worksheet cells of excel object.
for (int i = 0; i < GridView2.Rows.Count; i++)
{
for (int j = 0; j < GridView2.Rows[i].Cells.Count; j++)
{
xlWorkSheet.Cells[i + 1, j + 1] = GridView2.Rows[i].Cells[j].Text;
}
}
How do I get the values of GridView and store it in a worksheet, as the GridView2.Rows[i].Cells[j]
.Text returns empty string.