开发者

Dynamic gridview based on dropdown

开发者 https://www.devze.com 2023-01-25 20:55 出处:网络
I\'ve got a bit of an chicken and an egg. I need to bind a gridview to a set of database values.The gridview is dynamic and the columns, cells are created at run time.

I've got a bit of an chicken and an egg.

I need to bind a gridview to a set of database values. The gridview is dynamic and the columns, cells are created at run time.

As such, I need to re-bind the grid on every postback in the pre-init, init events after very post back.

However, the data used to populate the grid uses a开发者_如何学Python value from a dropdown box on the same page. As such, the value of dropdown is not accessible through viewstate until after the init event (i.e. the selected index is always the first item in the list until after on init).

How can I get access to the value of the drop down in time to rebind the grid before the pageload event?


If the Gridview always has the same number of columns, you could have the dynamic query generate column names as aliases, and then just rebind the Gridview on dropdown change?


you can use and HtmlHidden control for store the value you need. It doesn't depend by the viewstate and it's available into the page init

0

精彩评论

暂无评论...
验证码 换一张
取 消