Get selected value of Radlistview

5 posts, 1 answers
  1. Amirtha S
    Amirtha S avatar
    16 posts
    Member since:
    Feb 2010

    Posted 07 Apr 2010 Link to this post

    Hi
    I am using the Radlistview like a list of checkboxes and I can select multiple items out of it.

    How can I get the selected values on a Button click event?

    Here is my aspx code:

     <telerik:RadListView ID="rlv_Aircraft" runat="server"   
                                    AllowMultiItemSelection="True" ClientDataKeyNames="name"   
                                    DataSourceID="SqlDataSource_Aircraft" Skin="Black" 
                                    DataKeyNames="name" > 
                                    <LayoutTemplate> 
                                        <div class="RadListView RadListView_Black">  
                                            <table cellspacing="0" style="width:40px;">  
                                                <tbody> 
                                                    <tr ID="itemPlaceholder" runat="server">  
                                                    </tr> 
                                                </tbody> 
                                            </table> 
                                        </div> 
                                    </LayoutTemplate> 
                                    <ItemTemplate> 
                                        <tr class="rlvI">  
                                            <td width="20px">  
                                                <asp:Button ID="SelectButton" runat="server" CommandName="Select"   
                                                    CssClass="rlvBSel" Text=" " /> 
                                            </td> 
                                            <td width="60px">  
                                                <asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' /> 
                                            </td> 
                                            <td>&nbsp;  
                                            </td> 
                                        </tr> 
                                    </ItemTemplate> 
                                    <AlternatingItemTemplate> 
                                        <tr class="rlvA">  
                                            <td width="20px">  
                                                <asp:Button ID="SelectButton" runat="server" CommandName="Select"   
                                                    CssClass="rlvBSel" Text=" " /> 
                                            </td> 
                                            <td width="60px">  
                                                <asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' /> 
                                            </td> 
                                            <td>&nbsp;  
                                            </td> 
                                        </tr> 
                                    </AlternatingItemTemplate> 
                                    <EmptyDataTemplate> 
                                        <div class="RadListView RadListView_Black">  
                                            <div class="rlvEmpty">  
                                                There are no items to be displayed.</div> 
                                        </div> 
                                    </EmptyDataTemplate> 
                                    <SelectedItemTemplate> 
                                        <tr class="rlvISel">  
                                            <td width="20px">  
                                                <asp:Button ID="DeselectButton" runat="server" CommandName="Deselect"   
                                                    CssClass="rlvBSel" Text=" " /> 
                                            </td> 
                                            <td width="60px">  
                                                <asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' /> 
                                            </td> 
                                            <td>&nbsp;  
                                            </td> 
                                        </tr> 
                                    </SelectedItemTemplate> 
                                </telerik:RadListView> 
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Apr 2010 Link to this post

    Hello Amirtha S,

    Try the following code in order to access the selected items value in code behind.

    C#:
     
        protected void Button1_Click(object sender, EventArgs e) 
        { 
            foreach (RadListViewItem item in rlv_Aircraft.SelectedItems) 
            { 
                Label lbl = (Label) item.FindControl("nameLabel"); 
                string str = lbl.Text; 
                Response.Write(str); 
            } 
        } 

    Also go through the following documentation which might help you: Selecting items

    Thanks,
    Princy.
  3. Amirtha S
    Amirtha S avatar
    16 posts
    Member since:
    Feb 2010

    Posted 08 Apr 2010 Link to this post

    Thanks, Princy.
  4. Nahid
    Nahid avatar
    31 posts
    Member since:
    Aug 2010

    Posted 06 Apr 2011 Link to this post

    Hello Princy,
    I need to select RadListview Item on click with javascript.
    can you help me ...

    Thanks
    Nahid
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Apr 2011 Link to this post

    Hello Nahid,

    Please have a look at the following forum which illustrates how to select list item from client side.
    Clientside item select

    Thanks,
    Princy.
Back to Top