Last post Mar 17, 2008 11:59 AM by sbyard
Mar 17, 2008 11:59 AM|sbyard|LINK
I wanted to use a gridview that contained a dropdown for users to select a value from a list. The list should only require the insertion of a row in an SQL table and no code changes.
Here is a simple way to perform this - it really uses the minumum of code
------- The Custom Drop Down
// load the data for tis drop down and bind the control - only do this during the databind event, and not INIT or LOAD of the control, otherwise you may run into issues which I wont go into here
// you need to create a data source for your data - in my case, a dataset in the project was sufficient
WIthin the columns of your gridview, you add the column template based on your custom control registration.
When selecting your data, select both the ID and text used in the drop down. During viewing of the data, show the text, and during editing, bind to the integer value that represents it. This pair is usually in a separate table, linked by
foriegn key to the integer
gridview dropdownlist custom control