Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Datagrid Control (http://www.velocityreviews.com/forums/f60-asp-net-datagrid-control.html)
-   -   How to change data in grid after you change the SQL select for the data adapter (http://www.velocityreviews.com/forums/t762800-how-to-change-data-in-grid-after-you-change-the-sql-select-for-the-data-adapter.html)

tom c 06-06-2006 02:15 AM

How to change data in grid after you change the SQL select for the data adapter
 
I have an ASP.net webform with a datagrid on it.

I can change the SQL select statement for the grid in code by putting
a statement like this in the first line of Page_Load
OleDbDataAdapter1.SelectCommand.CommandText = "SELECT * from table
where ... "

The rest of the code in Sub Page_Load is

OleDbDataAdapter1.Fill(DsCategories1)
If Not IsPostBack Then
DataGrid1.DataBind()
End If

This works fine on the initial load of the the webform. If I want to
change the SQL command to load different data into the grid after the
form is loaded, and do that with a cmdButton, what code to I put under
the cmdButton to reload the webform or grid with the new sql select?


PeterKellner 06-08-2006 02:46 PM

Re: How to change data in grid after you change the SQL select for the data adapter
 
On 5 Jun 2006 19:15:20 -0700, "tom c" <tomcarr1@gmail.com> wrote:

>I have an ASP.net webform with a datagrid on it.
>
>I can change the SQL select statement for the grid in code by putting
>a statement like this in the first line of Page_Load
>OleDbDataAdapter1.SelectCommand.CommandText = "SELECT * from table
>where ... "
>
>The rest of the code in Sub Page_Load is
>
> OleDbDataAdapter1.Fill(DsCategories1)
> If Not IsPostBack Then
> DataGrid1.DataBind()
> End If
>
>This works fine on the initial load of the the webform. If I want to
>change the SQL command to load different data into the grid after the
>form is loaded, and do that with a cmdButton, what code to I put under
>the cmdButton to reload the webform or grid with the new sql select?


You would call DataBind() on your datagrid. This rexecutes the get
code in your bound datasource.
Peter Kellner
http://peterkellner.net


All times are GMT. The time now is 05:41 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.