Thirt
asked on
Hide/unhide column in Gridview at runtime
I have a dropdown control on my aspx page that I use to filter data in my gridview. I would also like to hide/unhide a column in the gridview based on the user dropdown select. Is there a way to do this. Searching for this and just find directions on how to hide the column at design time.
Using VB.
Using VB.
ASKER
Sorry, I didn't explain myself correctly. I have a dropdown that currently is used to filter data in the gridview. That part works fine. I have the Dropdown control used as a parameter in the gridview's select query. The user selects a value from the dropdown, presses the submit button and the gridview displays the correct data.
My problem is I can't figure out how to hide a column after the user selects a specific value in the dropdown. If they select "ValueX", I think I can add code to the Submit button on click event to do something to the effect...
if me.dropdown1 = "valuex" then
gridview.column(2).visible = false
else...
At least that's what I hope I can do. But I can't find the right code to do this.
My problem is I can't figure out how to hide a column after the user selects a specific value in the dropdown. If they select "ValueX", I think I can add code to the Submit button on click event to do something to the effect...
if me.dropdown1 = "valuex" then
gridview.column(2).visible
else...
At least that's what I hope I can do. But I can't find the right code to do this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Was missing an s in columns, but you idea works great.
Me.GridView1.Columns(2).Vi sible = (Me.DropDown1.SelectedValu e = "ValueX")
Me.GridView1.Columns(2).Vi
Bob