Non-Dynamic DropDown List in Datagrid
Posted on 2006-10-24
I have a datagrid with a dropdown list / text box (in template columns) as well as an update / delete button. The dropdownlist is a simple non-dynamic listing of numbers (1 - 100 - essentially an order list). The numbers have been inserted in a static fasion and as such are not coming from any database.
What I do need to do is somehow make the dropdownlist for each record display the selected database value so that the user can update the order list accordingly. To do this, I have set the SelectedIndex='<%# container.DataItem("ChapterOrder")%>' for this otherwise static dropdown. This seems to select values, but they are always off (a number or so above / below the real value).
When I select a value for a record listed in the dropdown list and then press the save button, the right number (the selected number) is being correctly inserted into the SQL database, but is not properly being represented after a page refresh, revisit or re-load.
Any thoughts as to how one can display the selected database item in a static dropdown in a datagrid?