Solution to Gridview?
-
I am doing a project using .net 2.0 C#. I used the SqlDataSource control to populate the database and then attach it to the gridview. The gridview works well if I run the code first time, meaning the gridview will display that SqlDataSource. But how can I achieve to display that SqlDataSource only upon user clicking a button called btnRefresh.:doh:
thanks in advance. Much appreciated.
-
I am doing a project using .net 2.0 C#. I used the SqlDataSource control to populate the database and then attach it to the gridview. The gridview works well if I run the code first time, meaning the gridview will display that SqlDataSource. But how can I achieve to display that SqlDataSource only upon user clicking a button called btnRefresh.:doh:
thanks in advance. Much appreciated.
In btnRefresh_click method only you open the connection and bind the gridview
-
I am doing a project using .net 2.0 C#. I used the SqlDataSource control to populate the database and then attach it to the gridview. The gridview works well if I run the code first time, meaning the gridview will display that SqlDataSource. But how can I achieve to display that SqlDataSource only upon user clicking a button called btnRefresh.:doh:
thanks in advance. Much appreciated.
There are many ways to do that: + You don't assign the id of the SqlDataSource control to the
DataSourceId
property of the GridView control until the button is clicked. + In the button click event handler, you can call the Select method of the datasource control and assign the result to the GridView control. + You can manage to populate the datasource instead of using the SqlDataSource control in the button click event handler. + You can keep doing the way that you are familar but only make the GridView control visible until the button is clicked. .... -
There are many ways to do that: + You don't assign the id of the SqlDataSource control to the
DataSourceId
property of the GridView control until the button is clicked. + In the button click event handler, you can call the Select method of the datasource control and assign the result to the GridView control. + You can manage to populate the datasource instead of using the SqlDataSource control in the button click event handler. + You can keep doing the way that you are familar but only make the GridView control visible until the button is clicked. ....Actually I have a textbox for user to key data and then when the user click btnSubmit, that data will be stored in the database.
minhpc_bk wrote:
+ You can keep doing the way that you are familar but only make the GridView control visible until the button is clicked.
I kind of like this method. However I encounter error, if I click btnRefresh, the database its not updated. :doh:
thanks in advance. Much appreciated.