Search code examples
c#asp.netlistviewtelerikrad-controls

Get subitem value in radlistview items


here is my listview

<telerik:RadListView runat="server" ID="lvAllUsers" Width="30px">
  <ItemTemplate>
    <table>
      <tr>
        <td >
          <asp:CheckBoxList ID="cbID" runat="server" CssClass="item" Font-Size="15px" RepeatDirection="Horizontal">
            <asp:ListItem Text="    "  > </asp:ListItem>
          </asp:CheckBoxList></td>
          <td style="padding-bottom:10px"><%# Eval("FirstName") %></td>
          <td style="padding-bottom:10px"><%# Eval("FamilyName") %></td>
        </tr>
      </table>
    </ItemTemplate>
 </telerik:RadListView>

how can I get checkboxlists item text at code behind ? or how can I get FirstName and FamilyName and code behind after I binded my data at pageload? I can't use

 foreach (Telerik.Web.UI.RadListViewItem item in lvAllUsers.Items) {
   var cb = item.FindControl(index);
 }

because index is equals an id normally. But in item template id is not equal to cbID. When item template iteratives, id is changing. I need get FirstName and FamilyName or checkboxlists item at codebehind (c# only not js). How can I do that?


Solution

  • I find the solution. It's seems like a little long way but it works.

    foreach (Telerik.Web.UI.RadListViewItem item in lvAllUsers.Items)
    {
        if (((System.Web.UI.WebControls.CheckBoxList)(((System.Web.UI.Control)(item)).Controls[1])).Items[0].Selected)
        {
            ccUserNames.Add(((System.Web.UI.WebControls.Label)(((System.Web.UI.Control)(item)).Controls[7])).Text);
        }
    }