Reputation: 293
I am using grid view control in my web application.Here i need to make label ,image and button controls into each single cell of grid view control.how to put controls into single cell.
Upvotes: 0
Views: 2057
Reputation: 6812
You can use TemplateField
to place multiple controls inside single cell:
<asp:GridView ID="grdView">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btn" />
<asp:Label ID="lbl" />
....
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Later in your code behind you can retrieve them using their id, you first have to get the reference to the individual row:
for (int i = 0; i < grdView.Rows.Count; i++)
{
if (grdView.Rows[i].RowType == DataControlRowType.DataRow)
{
Button objBtn = (Button)grdView.Rows[i].FindControl("btn"); //btn must match with the id defined in aspx page
Label objLbl = (Label)grdView.Rows[i].FindControl("lbl"); .....
}
}
Upvotes: 2