I'm using Visual Web Developer 2010 Express. This is my first attempt at creating a .NET page. I have a Gridview on a page that displays the results of a GridQuery. This works. I have a checkbox contr开发者_如何学Gool (cb_Filter) on the same page that if checked, should add to the where clause of the GridQuery, (where Column5 IS NULL). How do I check the state of the check box so it will run the query with or without the "filter".
really depends on your data access, if you have made a datasource on page, then you'll have two and the code will change which data source you have. if it is using the old ado.net then you will have two commands that run in seperate methods that get the sql query, and a similar thing will work for linq. Let me know how you bind to the grid and i will give you an example.
If you want the grid results to change dynamically, autopostback should be True for the checkbox. This will cause the page to reload when the value changes. Then, in your page load routine you do something like this:
If cb_filter.Checked Then
'set the checked datasource or SQL string here
Else
'set the unchecked datasource or SQL string here
End If
精彩评论