Losting selecteditem in listview

2 posts, 0 answers
  1. Baris
    Baris avatar
    34 posts
    Member since:
    Jul 2013

    Posted 27 Feb 2014 Link to this post


    here is my listview

     <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
    <telerik:RadTextBox ID="txtDSTableLike" runat="server" EmptyMessage="Table Like" OnTextChanged="txtDSTableLike_TextChanged"></telerik:RadTextBox>
                                    <div class="table-selection-list">
                                        <div id="content_1_1" class="contents_1">
                                            <telerik:RadListView ID="lvDSTableSelection" runat="server" AllowMultiItemSelection="true" OnSelectedIndexChanged="lvDSTableSelection_SelectedIndexChanged" autopostback="false">

                                                    <asp:LinkButton ID="LinkButton1" CssClass="selectedButtons" runat="server" CommandName="Select" Font-Underline="false">
                                                    <p ><%# Container.DataItem %></p></asp:LinkButton>
                                                <SelectedItemTemplate >
                                                    <p ><%# Container.DataItem %></p>

    First of all Icall this function and SelectedItems returns selected data perfectly

            protected void lvDSTableSelection_SelectedIndexChanged(object sender, EventArgs e)

                orcl.Owner = ddDSSchema.SelectedText;
                orcl.TableName = lvDSTableSelection.SelectedItems[0].DataItem.ToString(); --> returns selected data perfectly
                var result = client.GetColumnNames(orcl);

                lbDSNominal.DataSource = result.Data;

    after I call above function, I call this function but now SelectedItems  return null

     protected void btnNext_Click(object sender, EventArgs e)

                developmentSample.TableName = lvDSTableSelection.SelectedItems[0].DataItem.ToString(); --> return null at selected item

    how can I fix it? Why am I losting selecteditem ?

  2. Viktor Tachev
    Viktor Tachev avatar
    1444 posts

    Posted 04 Mar 2014 Link to this post

    Hi Baris,

    If you have defined the values that you would like to extract from a selected item you could use SelectedValue or SelectedValues methods. Also you could access a value if a selected item using GetDataKeyValue() method.

    Different approaches on how to extract values from a selected item in RadListView are described in this article. Try using one of the approaches listed there and you should achieve the functionality you are looking for. There is also an online demo on selecting items in RadListView available here.

    Viktor Tachev
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top