M
Mantova
Maybe it's simple, but I can't get it to work.
I'm originally a webdeveloper, and just started to work on a C# windows
application.
I want a list, something similar to a <select><option> object, where the
displayed value is different from the real value.
I populate the list like this, where I assume that SelectedValue is
something like the <option value="ID">
while (sql.Read())
{
currentItem=this.List.Items.Add(sql["name"]);
List.SelectedIndex=currentItem;
List.SelectedValue=sql["id"];
}
Now when I select an item in the list and do something like
textbox.Text=List.SelectedValue.ToString();
it gives me an error.
Debugging gives me a <undisplayable value> for the SelectedValue.
What am I doing wrong here?
I'm originally a webdeveloper, and just started to work on a C# windows
application.
I want a list, something similar to a <select><option> object, where the
displayed value is different from the real value.
I populate the list like this, where I assume that SelectedValue is
something like the <option value="ID">
while (sql.Read())
{
currentItem=this.List.Items.Add(sql["name"]);
List.SelectedIndex=currentItem;
List.SelectedValue=sql["id"];
}
Now when I select an item in the list and do something like
textbox.Text=List.SelectedValue.ToString();
it gives me an error.
Debugging gives me a <undisplayable value> for the SelectedValue.
What am I doing wrong here?