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

ItemDataBound in Detail Grid

1 Answer 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 21 Dec 2010, 05:24 PM
Is it possible to access an ItemDataBound routine for a detail table?

What I want to do is toggle fields based on permissions as well as edit the text in a label. The detail table has a item template:

<ItemTemplate>
<table width="100%">
<tr>
<td style="width:250px;" >
Created by: <%# Eval("created_by")%><br />
Created On: <%# Eval("created_on""{0: ddd MM/dd/yy hh:mm}")%><br />
<asp:Label ID="lblNoteType" runat="server" Text="" Visible="false" />
<asp:Label ID="lblNoteTypeData" runat="server" Text='<%# Eval("note_type")%>' Visible="false" />
</td>
<td>
<%# Eval("note")%>
</td>
</tr>
</table>
</ItemTemplate>

I am trying to toggle lblNoteType visible and invisible based on permissions as well as change the text property.



I put a name on the detail grid and setup a
    Protected Sub gvNotes_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs)
event, but that didn't work, setting
<telerik:GridTableView Name="gvNotes" OnDataBound="gvNotes_ItemDataBound" 
on the detail grid didn't launch the event either.
What is the best way to do this?
Thanks
Randy Miller
TransGuardian

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Dec 2010, 05:41 AM
Hello Randy,

You can distinguish the rows in hierarchy on ItemDataBound event itself. One option is to utilize the Name property of each GridTableView like below.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "gvNotes")
       {
           GridDataItem item = (GridDataItem)e.Item;
           Label lbl = (Label)item.FindControl("lblNoteType");//accessing Label control in DetailTable
           . . . . .
       }
   }

For more information on this please refer the following documentation.
Distinguish grid rows in hierarchy on ItemCreated/ItemDataBound

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