views:

21

answers:

2

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.

+1  A: 

Setting the property:

mydropdown.SelectedItem

or mydropdown.SelectedValue

Make sure you do this AFTER databinding the dropdown control.

Ahmed Khalaf
ddparty.SelectedIndex = ddparty.Items.IndexOf(ddparty.Items.FindByValue(ds.Tables[2].Rows[0][1].ToString()));is this correct
Ayyappan.Anbalagan
Yes, this is how you do it by hand :)
Ahmed Khalaf
but its not working man
Ayyappan.Anbalagan
A: 

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.

Veer