Referencing nested server-side IDs

  • Thread starter Thread starter King Coffee
  • Start date Start date
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
 
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 = "...";
}

}
 
Back
Top