How can I find asp.net's control where it is in ultrawebgrid's TemplatedColumn when I worked C# code.
sample:
<igtbl:TemplatedColumn>
<CellTemplate>
<asp:Label ID="lbl" runat="server" Text="Label"/>
</CellTemplate>
</igtbl:TemplatedColumn>
If you want to access controls from different column then addition to above post follow this:
(1) Get reference of row generating item command
UltraGridRow row = cellItemCol1.Cell.Row;
(2) Using row object get another column and get controls in it. (Refer my first post and replace e.Row with row)
Hi,
Try following code.
protected void grid1_ItemCommand(object sender, UltraWebGridCommandEventArgs e)
{
CellItem cellItemCol1 = e.ParentControl as CellItem;
if (cellItemCol1 != null)
Image imgCol1 = (Image)cellItemCol1.FindControl("imgCol1");
Label lblCol1 = (Label)cellItemCol1.FindControl("lblIsCol1");
}
Let me know if this helps you.
Thinks you answer. Your way is in grid1_InitializeRow Event, if I want in grid1_ItemCommand Event, how can I get aps.net's control?
You can find controls from TemplateColumn at row level. You could refer following code for detail
You need to use following type of markup in aspx file.
<igtbl:TemplatedColumn Key="Col1" >
<asp:Image ID="imgCol1" runat="server" />
<asp:Label ID="lblCol1" runat="server" />
To access above controls you can use following C# code.
protected void grid1_InitializeRow(object sender, RowEventArgs e)
TemplatedColumn col1 = (TemplatedColumn)e.Row.Cells.FromKey("Col1").Column;
CellItem cellItemCol1 = (CellItem)col1.CellItems[e.Row.Index];
Label lblCol1 = (Label)cellItemCol1.FindControl("lblCol1");
In above code imgCol1 and lblCol1 will be controls inside template column keyed as Col1 for particular row.