“Input string was not in a correct format.”

后端 未结 5 1981

I am working on a project in which I have a form through which I can edit a question available in a list view. Whenever I select a row from the list view and click on the \'

5条回答
  •  孤街浪徒
    2020-12-11 02:45

    It looks like some space include in the text. Use

    lvTwoOrMoreOptions.SelectedItems[0].Text.ToString().Trim()

    and convert to int32.

    hope this code will solve you

    From comments

    if your ListView is in report mode (i.e. it looks like a grid) then you will need the SubItems property. lvTwoOrMoreOptions.SelectedItems gets you each items in the list view - SubItems gets you the columns. So lvTwoOrMoreOptions.SelectedItems[0].SubItems[0] is the first column value,

提交回复
热议问题