Si_Hibbard
asked on
Gridview - populating dropdownlist in codebehind
hi Guys,
I am having a nightmare with this, i really hate using gridviews.
Anyway, basically i have a dropdown list in a gridview, which i want to bind to a datasource and populate it from codebehind (this allows me to populate it from a file listing).
I have tried to populate the list in just about all the gridview events, rowupdating, databound etc but as soon as i hit edit in the gridview i get an error stating the selectedvalue does not exist - thats because it is trying to set the selectedvalue (needed to bind it) before i can populate it.
So summary:
I click on the gridview edit button, which event do i use to populate the dropdown - without getting the
"SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value"
god this should be so simple.
I am having a nightmare with this, i really hate using gridviews.
Anyway, basically i have a dropdown list in a gridview, which i want to bind to a datasource and populate it from codebehind (this allows me to populate it from a file listing).
I have tried to populate the list in just about all the gridview events, rowupdating, databound etc but as soon as i hit edit in the gridview i get an error stating the selectedvalue does not exist - thats because it is trying to set the selectedvalue (needed to bind it) before i can populate it.
So summary:
I click on the gridview edit button, which event do i use to populate the dropdown - without getting the
"SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value"
god this should be so simple.
if your gridview has a autogenerated edit button then bind it in the row_editing event of the datagrid
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
Vee_Mod
Community Support Moderator