A control can be added to a gridview using the rowdatabound event.
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Image img = new Image();
img.ImageUrl = "~/images/logo.png";
TableCell tcell = new TableCell();
tcell.Controls.Add(img);
//The control will be added to second cell of the gridview.
e.Row.Cells[2].Controls.Add(img);
}
}
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Image img = new Image();
img.ImageUrl = "~/images/logo.png";
TableCell tcell = new TableCell();
tcell.Controls.Add(img);
//The control will be added to second cell of the gridview.
e.Row.Cells[2].Controls.Add(img);
}
}
No comments:
Post a Comment