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

Losting selecteditem in listview

1 Answer 58 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Baris
Top achievements
Rank 1
Baris asked on 27 Feb 2014, 09:44 AM
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 ?




1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 04 Mar 2014, 09:43 AM
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.
Tags
ListView
Asked by
Baris
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or