This is a migrated thread and some comments may be shown as answers.

GridTableView Templatecolumn Programmatically

1 Answer 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Het
Top achievements
Rank 1
Het asked on 22 Aug 2008, 02:54 PM
I have a Mastertableview and detailstableview.

I want to have a gridtemplatecolumn in GridTableView, and want to assign the value at runtime.

Say my GridTemplateColumn has a label and I want to set the value of the label programmatically in some event (like in simple grid we do it in OnItemDataBound), but here we do not have OnItemDatabound.

Thanks,
Het

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 25 Aug 2008, 05:12 AM
Hello Het,

From my understanding, I suppose that you have created the TemplateColumn and a Label in it, statically. If this is the case, then you can set the value of the Label in the TemplateColumn of a DetailTable in the ItemDataBound event of the Grid by using the DetailTables Name property as shown below.
aspx:
 <DetailTables> 
    <telerik:GridTableView Name="Detail" DataSourceID="SqlDataSource1"
      <Columns>         
        <telerik:GridTemplateColumn> 
        <ItemTemplate> 
            <asp:Label ID="Label1" runat="server"></asp:Label> 
        </ItemTemplate> 
        </telerik:GridTemplateColumn> 
      </Columns> 
    </telerik:GridTableView> 
 </DetailTables>    

cs:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Detail") 
        { 
            GridDataItem data = (GridDataItem)e.Item; 
            Label lbl = (Label)data["PlaceFrom"].FindControl("Label1"); 
            lbl.Text = "Label"
        } 
    } 

Thanks
Princy.
Tags
Grid
Asked by
Het
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or