I have got 2 DropDownLists on my Form and 1 GridView. I want the GridView to display the data according to the selection from the DropDownLists.
For Example, One DropDownList contains Names and another contains Dates. Both the DropDownLists can post back. So if I select a name from 1st DropDownList, the GridView should show all the results according to that Name. Similarly if i select the Date from the other DropDownList , the GridView should show the results according to the dates. But i cant figure out as how to bind GridView to respond to 2 DropDownList.
BTW i am binding both the Drop Down Lists and the Grid View to the DataSource Objects, which is getting data from the database.
Any Suggestions??
It’s better and cleaner if You use two
DataSourcewith selecting data from db, and binding each of them to theDropDownList. I tried in my ASP.NET app do what You want but unfortunatelly I have erorrs :/My only sollution is to don’t use
DataSoucein aspx file, but inDropDownListSelectedItemevent useDataContextand it’s possible that then you could bind both to the sameDataViewlike below. I am not sure, but maybe You must use null inDataSourceto resetGridViewbefore use new data source:Try it and tell say that works 😉