Editable GridView Distinct Drop Down LIsts
I have a simple app I am messing around with its a basic Master/Details layout.
The details panel is actually a tab panel and on one of the tab panels it has a GridView. Within th开发者_运维问答at grid view it shows the "current" in database information with all cells as read only.
alt text http://lh4.ggpht.com/_JU1W2P96pD4/TAeonNNYXgI/AAAAAAAAAq0/Y_-Kse7VObE/ExampleA.jpg
I then have an add button that inserts a row into the GriView and allows the user to enter some information. The first item in my GridView is a DropDownList, which is populated from an ObjectDataSource. This drop down is basically my unique index and there can only be one selected value per GridView.
alt text http://lh3.ggpht.com/_JU1W2P96pD4/TAeonIF3DdI/AAAAAAAAAq4/JhfOTsHgsf8/ExampleWithDropDown.png
What is the best way to remove the values from the list that are already in the GridView? Do I just need to remove the data source and add a OnDataBinding method that iterates through the grid view and generates a valid list of values?
I can't use a service method because if the user adds two rows they would have the option to insert duplicates description types.
Just want to make sure there is not a better way to do this.
Keep the object datasource, which I am assuming is an IEnumerable object, in a Session variable. When someone selects a certain value remove that value from the list in the session variable. Whenever they activate the form where the drop down list is displayed simply rebind the control to the list in the session variable. It will be easier than looping through the grid every time the user adds an entry.
精彩评论