Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 08, 2013 03:39 AM by sanjayverma_mca
Member
6 Points
9 Posts
Jan 01, 2013 03:03 PM|LINK
I have a listview lv_category in page Product.aspx, how do I get the value of the selected CategoryName using C#?
I've tried lv_category.SelectedValue and it does not work.
<asp:ListView ID="lv_category" runat="server" DataKeyNames="CategoryID" DataSourceID="SqlDataSource1"> <ItemTemplate> <td runat="server" style=""> <asp:LinkButton ID="hb_category" runat="server" OnClick="hb_Click" Text='<%# Eval("CategoryName") %>'></asp:LinkButton> </td> </ItemTemplate> <LayoutTemplate> <table runat="server" style="width:100%"> <tr id="itemPlaceholderContainer" runat="server"> <td id="itemPlaceholder" runat="server"></td> </tr> </table> <div style=""> </div> </LayoutTemplate> </asp:ListView>
305 Points
73 Posts
Jan 01, 2013 03:07 PM|LINK
hai
try this
http://stackoverflow.com/questions/570801/programmatically-select-item-in-asp-net-listview
All-Star
21600 Points
2493 Posts
Microsoft
Jan 08, 2013 02:37 AM|LINK
Hi,
You could follow @0ramramram0's link, it will help you to find selected item in listview when you DataBound. You could use selectedIndex to make sure you have selected an item, use ListViewDataItem item to get your item.
More information: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listviewitemeventargs.item.aspx
Best Regards,
Participant
1476 Points
350 Posts
Jan 08, 2013 03:39 AM|LINK
Hi AmuletxHeart,
Use foreach to get all the selected value in the listbox.Within foreach use if condition to check the selected value and get it in variable.
Hope this will help you ...........
AmuletxHeart
Member
6 Points
9 Posts
How to get selected value from a ListView
Jan 01, 2013 03:03 PM|LINK
I have a listview lv_category in page Product.aspx, how do I get the value of the selected CategoryName using C#?
I've tried lv_category.SelectedValue and it does not work.
<asp:ListView ID="lv_category" runat="server" DataKeyNames="CategoryID" DataSourceID="SqlDataSource1"> <ItemTemplate> <td runat="server" style=""> <asp:LinkButton ID="hb_category" runat="server" OnClick="hb_Click" Text='<%# Eval("CategoryName") %>'></asp:LinkButton> </td> </ItemTemplate> <LayoutTemplate> <table runat="server" style="width:100%"> <tr id="itemPlaceholderContainer" runat="server"> <td id="itemPlaceholder" runat="server"></td> </tr> </table> <div style=""> </div> </LayoutTemplate> </asp:ListView>0ramramram0
Member
305 Points
73 Posts
Re: How to get selected value from a ListView
Jan 01, 2013 03:07 PM|LINK
hai
try this
http://stackoverflow.com/questions/570801/programmatically-select-item-in-asp-net-listview
Chen Yu - MS...
All-Star
21600 Points
2493 Posts
Microsoft
Re: How to get selected value from a ListView
Jan 08, 2013 02:37 AM|LINK
Hi,
You could follow @0ramramram0's link, it will help you to find selected item in listview when you DataBound. You could use selectedIndex to make sure you have selected an item, use ListViewDataItem item to get your item.
More information: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listviewitemeventargs.item.aspx
Best Regards,
Feedback to us
Develop and promote your apps in Windows Store
sanjayverma_...
Participant
1476 Points
350 Posts
Re: How to get selected value from a ListView
Jan 08, 2013 03:39 AM|LINK
Hi AmuletxHeart,
Use foreach to get all the selected value in the listbox.Within foreach use if condition to check the selected value and get it in variable.
Hope this will help you ...........