Dropdown Select issue on Edit Command in Grid
-
28-06-2021 - |
Question
I have a grid . I am filling my grid . In that i have edit button . when i click edit all the values in the grid should be selected in my otherpage DROPDOWN.
ddlconfemail.SelectedItem.Text = item["scoreconfirmeemail"].Text;
If i use this i get duplication meaning my initial item index of zero which is (--please select--)get replaced by this item .
but if i use this
ddlconfemail.selectedvalue = item["scoreconfirmeemailid"].Text;
This works perfect .
The thing is i have 12 dropdown . I Cant map all id`s to my grid . HAVE TO CHANGE ALOT .
ANy other solution avaiable ?
La solution
You can use FindByText of dropdown items i.e.
ddlconfemail.SelectedValue = ddlconfemail.Items.FindByText(item["scoreconfirmeemail"].Text).Value;
Hope this will help you.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow