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

how to get ListView selectedItem value?

2 Answers 911 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Hamed
Top achievements
Rank 1
Hamed asked on 12 Apr 2013, 11:38 PM
Hi

I have ListView  with data and i need text value of selectedItem , when i use this code :

this.label1.Text = this.lstUser.SelectedItem.Text.ToString().Trim();

it returns:  "System.Data.DataRowView"

I also used this code :

this.txtUserPass1.Text = this.lstUser.Items[lstUser.SelectedIndex].Value.ToString().Trim();

when i use data set control its fine and it returns Correct value (for example UserName)!

What have I done wrong?

2 Answers, 1 is accepted

Sort by
0
Hamed
Top achievements
Rank 1
answered on 16 Apr 2013, 05:22 PM
anyone here?
0
Accepted
Stefan
Telerik team
answered on 17 Apr 2013, 03:32 PM
Hi Hamed,

Thank you for writing.

Can you please check whether you can the correct DIsplayMember set of your control? If this is not the case, please get back to me with a sample allowing me to reproduce the undesired behavior and I will do my best to help you with it.
 

Kind regards,
Stefan
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
Tags
ListView
Asked by
Hamed
Top achievements
Rank 1
Answers by
Hamed
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or