How to change data in grid after you change the SQL select for the data adapter
by tom c » Wed, 07 Jun 2006 11:15:20 GMT
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?
Re: How to change data in grid after you change the SQL select for the data adapter
by PeterKellner » Fri, 09 Jun 2006 23:46:11 GMT
You would call DataBind() on your datagrid. This rexecutes the get
code in your bound datasource.
Peter Kellner
http://www.**--****.com/
Similar Threads:
1.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?
2.Changing row height in a data grid without changing font size
How do you change the row height in a data grid - I do not want to increase
the height by changing my font size. My product is a touch screen so I have
to make the row height large enought for a finger press.
3.reflect changes in data bound control when underlying data table changes
[Little correction]
Hi,
I have a form on which I have 2 datagrid view.
1) for table "route" - Structure : route char(3), dock int
2) for table "lanes" - Structure: laneid char(3), laneName char(6),
lanetype char(2), dock1 int, dock2 int, dock3 int, dock4 int, dock5 int
The various docks in table lanes are actually values in the table
route's dock. But it's not a foreign key. Nor is the dock unique in the
route table. There can be multiple entry for a single value of dock.
Also database can be change under any circumstances.
For DataGridView of table lanes, I needed to display the available docks
in a combo box. So, I created another dummy table (dummy_docks) whose
select query is
"select distinct dock from route order by dock"
This dummy_docks table is used as data source for dock1, dock2....,
dock5 columns (combo box columns) of the data grid view of table lanes.
When the application initializes, the adapter fills the table
dummy_docks and the values are displayed in the combo box of the data
grid view of table lanes.
But after that if any row is added to table route then the new value of
dock is not reflected in the combo box in the data grid view of lanes.
I tried to update the changes in route table by calling update on the
data adapter and clear & re-fill the table dummy_docks using the
adapter, but it doesn't help.
How can I make the changes reflect in the data bound combo box of the
data grid view.
Thanks & Regards,
Ashutosh