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

Access a column from NestedViewTemplate itemdatabound

2 Answers 215 Views
Grid
This is a migrated thread and some comments may be shown as answers.
kiteloop
Top achievements
Rank 1
kiteloop asked on 25 Aug 2010, 02:33 PM
Hi,

Is there a better way to access the litConnected from the the ItemDataBound event, I donĀ“t like the concept to calculate stuff to make it work, must be a better way?


<telerik:RadGrid ID="activeGrid" runat="server" OnItemDataBound="activeGrid_ItemDataBound" AutoGenerateColumns="false"  EnableAjaxSkinRendering="true" EnableAjax="true">
                <MasterTableView Name="active">
                    <Columns>
                        <telerik:GridBoundColumn DataField="name" HeaderText="Name" />
                        <telerik:GridBoundColumn DataField="thingie" HeaderText="Thing2" />
                        <telerik:GridTemplateColumn>
                            <ItemTemplate>
                                <asp:Literal runat="server" ID="litConnected" />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                    <NestedViewTemplate>
                       Here be things..
                    </NestedViewTemplate>
                </MasterTableView>
</telerik:RadGrid>
protected void activeGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
   if(e.Item.ItemType != GridItemType.NestedView)
         return;
   var litConnected = activeGrid.MasterTableView.Items[e.Item.RowIndex / 3 - 1].FindControl("litConnected") as Literal;
 
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 25 Aug 2010, 02:47 PM
Hello,

Here is the code snippet which shows hwo to access the Literal control in ItemDataBound event.
CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        Literal ltrl = (Literal)item.FindControl("litConnected");
        ltrl.Text = "haia";
    }
}


Thanks,
Princy.
0
kiteloop
Top achievements
Rank 1
answered on 25 Aug 2010, 03:10 PM
Thanks!
So simple but idiotic by me.
Tags
Grid
Asked by
kiteloop
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
kiteloop
Top achievements
Rank 1
Share this question
or