Referencing nested server-side IDs

K

King Coffee

Hi,

I need help in referencing nested server-side IDs. I have an asp:GridView
ID="GridView1" control. The columns tag contains an asp:Image ID="Image1"
control. How can I set the Image1 ImageUrl attribute in the codebehind file
?

King
 
G

Guest

Hi,

I need help in referencing nested server-side IDs. I have an asp:GridView
ID="GridView1" control. The columns tag contains an asp:Image ID="Image1"
control. How can I set the Image1 ImageUrl attribute in the codebehind file
?

King

Use RowDataBound event
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx

void CustomersGridView_RowDataBound(Object sender,
GridViewRowEventArgs e)
{

if(e.Row.RowType == DataControlRowType.DataRow)
{
Image img = e.Row.FindControl("Image1") as Image;
img.ImageUrl = "...";
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top