Gagan Gautam

Gagan Gautam

  • NA
  • 140
  • 15k

Retive Gridview Data Row by row and store in variable

Dec 9 2016 12:48 PM
Hi,
I am using GridView AutogenrateColumn=False .This is my  Gridview code 
 ______________________________________________________________________
<asp:GridView ID="gridview1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="Ischeck" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Id">
<ItemTemplate>
<asp:Label ID="id" runat="server" Text='<%#Eval("Id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Product Name">
<ItemTemplate>
<asp:Label ID="lblPrductName" runat="server" Text='<%#Eval("ProductName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description">
<ItemTemplate>
<asp:Label ID="lblObjName" runat="server" Text='<%#Eval("ObjName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:Label ID="lblQuantity" runat="server" Text='<%#Eval("Quantity") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
_____________________________________________
 
Now i am  retrive   data of grid view row by row.,So this is my code,In this code i am retriveing data in two ways but i am not able retive data.Plzz help me
_________________________________________________
protected void btn_Click(object sender, EventArgs e)
{
foreach (GridViewRow item in gridview1.Rows)
{
string name = item.Cells[2].Text.ToString();  // 1st way
var nn =(Label) item.FindControl("ProductName"); //2nd Way
}
}
 
 

Answers (1)