Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Example :
//cs

Control control = null;

control = GridView1.Controls[0].Controls[0];
string proCode = Convert.ToString((control.FindControl("lblProductCode") as Label).Text);
Label1.Text = proCode;

//aspx
<asp:TemplateField HeaderText = "Product Code">
<itemtemplate>
<asp:Label ID="lblProductCode" runat="server" Text='<%#Eval("productCode") %>'>



<asp:Label ID="Label1" runat="server" Text="Label">

Result:
Object reference not set to an instance of an object.
how to match the current row value?
Posted
Comments
ZurdoDev 25-Mar-14 22:34pm    
Apparently the control you are looking for is not in GridView1.Controls[0].Controls[0]. I'm not sure why you are looking there, most people look in the row and in a row event they would do row.FindControl.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900