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

    hi,

    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>
                                    <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">

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



    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;
                lbDSNominal.DataBind();
            }

    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
    Admin
    Viktor Tachev avatar
    1488 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.

    Regards,
    Viktor Tachev
    Telerik
    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. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top