how to get ListView selectedItem value?

3 posts, 1 answers
  1. Hamed
    Hamed avatar
    2 posts
    Member since:
    Apr 2013

    Posted 12 Apr 2013 Link to this post

    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. Hamed
    Hamed avatar
    2 posts
    Member since:
    Apr 2013

    Posted 16 Apr 2013 Link to this post

    anyone here?
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 17 Apr 2013 Link to this post

    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.
Back to Top