W
writebrent
This is my code:
HtmlSelect m = new HtmlSelect();
m.ID = "m1";
m.DataSource = dvBasic; //DataView created elsewhere
m.DataTextField = "value";
m.DataValueField = "key";
m.Value = "2"; //<----NOT WORKING
ctrlsPlaceHolder.Controls.Add(m);
this.DataBind();
The docs state in relevant part:
HtmlSelect.Value: "... or sets the SelectedIndex property of the
control to the index of the first item in the list with the specified
value."
Shouldn't my code set the SelectedIndex to, say, 1, if "2" is the
value of the list item at index 1? It's not doing this, but instead
just displaying the first list item.
Thanks for any help!
Brent
HtmlSelect m = new HtmlSelect();
m.ID = "m1";
m.DataSource = dvBasic; //DataView created elsewhere
m.DataTextField = "value";
m.DataValueField = "key";
m.Value = "2"; //<----NOT WORKING
ctrlsPlaceHolder.Controls.Add(m);
this.DataBind();
The docs state in relevant part:
HtmlSelect.Value: "... or sets the SelectedIndex property of the
control to the index of the first item in the list with the specified
value."
Shouldn't my code set the SelectedIndex to, say, 1, if "2" is the
value of the list item at index 1? It's not doing this, but instead
just displaying the first list item.
Thanks for any help!
Brent