Click here to Skip to main content
15,919,245 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more: (untagged)
Hi all,

i am trying to get the text from a label that it is inside of a detailsview field. This field is in fact a template field, and inside its ItemTemplate there is the Label control (ID = "Label8") which Text property i want to read.

i tried the following without success (returns c = null):

System.Web.UI.Control c = dvCU.FindControl("Label8");<br />                string s = ((System.Web.UI.WebControls.Label)c).Text;<br />

can anyone help me?

Thanks in advance.

modified on Tuesday, April 7, 2009 4:27 PM
Posted

1 solution

where is your code. In other words, which method is your code in.

you can not get the controls the way you are showing.

1. you need to access your details view control
2. then you need to access specific row in the control
3. then you need to do a find

protected void grdItemDetail_RowDataBound(object sender, GridViewRowEventArgs e)<br />{<br /> Image img = (Image)e.Row.FindControl("Thumbnail");<br />}

 
Share this answer
 


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