Click here to Skip to main content
15,922,315 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
could you please help me in Find control in Detail view below is my cs and aspx code.when i run this code getting null




Label compname = DetailsView1.Rows[0].Cells[1].FindControl("complbl") as Label;
comp = compname.Text;


<asp:TemplateField HeaderText="Company Name">
  <itemtemplate>
                                                                            <asp:Label ID="complbl" runat = "server">
                                                                        </itemtemplate>


Thanks
Posted

try this instead,


C#
compname = (Label)DetailsView1.Rows[0].Cells[1].FindControl("complbl");


hope it helps,

thanks
 
Share this answer
 
v2
Comments
Lancy.net 25-Nov-11 5:09am    
thanks it is not working
D K N T H 25-Nov-11 5:22am    
try this

Label lbl;
string labelText = string.empty;

lbl = (Label)DetailsView1.Rows[0].Cells[1].FindControl("complbl");
lableText = lbl.text;

hope it helps


please mark this as answer if it helps you

thanks ..
remove as Label and try i the following way:
C#
label lbl1 = (Label)DetailsView1.Rows[0].Cells[1].FindControl("complbl"); lable1.Text = lbl1.Text ;
 
Share this answer
 
Comments
Lancy.net 25-Nov-11 6:04am    
Thanks for your reply.. still the same

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