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,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top