Why I get “System.Data.DataRowView” instead of real values in my Listbox?

前端 未结 12 822
一向
一向 2020-11-29 08:24

I\'m hoping someone can help. But whenever I run my code and try to view a highscore all I get back in my listbox is System.Data.DataRowView.

12条回答
  •  醉酒成梦
    2020-11-29 09:18

    I know its an old question. Just thought it might be nice to add an update to the answers given already. I was looking for a solution to the same problem. I the realized it is in which order you place these 3 lines of code

    lstNames.DisplayMember = "NameAndScore";
    lstNames.ValueMember = "NameAndScore";
    lstNames.DataSource = dTable;
    

    It should use the datasource first. Then The value member and then the display member As follow:

    lstNames.DataSource = dTable;
    lstNames.ValueMember = "NameAndScore";
    lstNames.DisplayMember = "NameAndScore";
    

提交回复
热议问题