Reputation: 41
I have a simple dropdownlist with let's say 3 entries: "WLTP", "NEDC", "RDE" outside of a gridview.
Then I have a normal gridview with these column-names: "ID", "Name", "WLTP", "NEDC", "RDE".
I get the data through ADO.net from an Access database.
Now, what I simply want is that the user clicks on the dropdownlist and selects one entry, e.g. "NEDC".
Now, the colums "ID", "Name" should always be displayed, but only the column "NEDC" should be displayed, not the remaining "WLTP" and "RDE".
My question: Do I have to modify my SELECT QUERY in code which was originally:
SELECT ID, Name, WLTP, NEDC, RDE FROM tblName;
to the reduced version:
SELECT ID, Name, NEDC FROM tblName;
But this is not efficient to do another database connect right?
Can I simply filter the gridview itself?
Regards!
Upvotes: 0
Views: 104
Reputation: 8892
No you don't need to change the sql query and hit the database each time. Instead you can use the DropdownList_SelectedIndexChagned
Event of the list and in that event you can set the gridview columns visibility.Here is more info on the event.
Here is one tutorial explains how to do it.
Upvotes: 1