Reputation: 11302
Based on my dataset row value , my drop drown will focus the particular list item in page load event.
ddparty.SelectedIndex = ddparty.Items.IndexOf(ddparty.Items.FindByValue(ds.Tables[2].Rows[0][1].ToString()));
i try the above code its not working.
Upvotes: 1
Views: 2848
Reputation: 12944
Don't know if you've set your DataValueField to the datatable's second column. On the other hand if you've set your DataTextField to it, try FindByText instead of FindByValue.
As a side note, try to quickwatch in the debugger, the value of the index you get.
Upvotes: 0
Reputation: 1220
Setting the property:
mydropdown.SelectedItem
or mydropdown.SelectedValue
Make sure you do this AFTER databinding the dropdown control.
Upvotes: 1