I am using a datagrid and want to change the view interactively in the app.
I am using a combobox to select a state, and want to filter the dataset which contains every state.
But this code does not empty the existing contents from the datagrid and fill it with the new view results.
Here is the code -- the statement that intializes mydataview seems to be returning a reasonable number of rows per request.
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim str As String
Dim MyCommand As OleDb.OleDbDataAdapter = OleDbDataAdapter1
Dim DS As New db2DataSet
str = "State = " + ComboBox1.Text
Dim mydataview As New DataView(DS.Tables("counties"), str, "SORT = DIVORCED", DataViewRowState.CurrentRows)
Me.DGDetails.DataSource = "" 'Me.DGDetails is the current datagrid. This line is intended to empty the datagrid.
Me.DGDetails.DataSource = mydataview ' This line should fill the datagrid with the filtered results of the mydataview instance.
End Sub
****************************************
I would welcome a link to an example that uses this method, or a parameterized query to accomplish the same thing. I am coding in VB2010 and haven't upgraded the datagrid to a datagridview for several reasons not relevant here. Thanks for any help.
You need to bind data after Ading new data in datasource.
like this:
Me.DGDetails.Databind();
Thanks, but there is no "DataBind()" method for the datagrid....only a "DataBindings()" that requires some parameters, and I have gotten nowehre with that. Maybe DataBind() works with DataGridView.
I am not using the DataGridView because I started this project years ago and have too much code depending on the DataGrid to change it very easily.
zeitguy
0 Points
3 Posts
Update Datagrid with DataView - VB2010, ASP.NET 4
May 01, 2012 06:25 PM|LINK
I am using a datagrid and want to change the view interactively in the app.
I am using a combobox to select a state, and want to filter the dataset which contains every state.
But this code does not empty the existing contents from the datagrid and fill it with the new view results.
Here is the code -- the statement that intializes mydataview seems to be returning a reasonable number of rows per request.
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim str As String
Dim MyCommand As OleDb.OleDbDataAdapter = OleDbDataAdapter1
Dim DS As New db2DataSet
str = "State = " + ComboBox1.Text
Dim mydataview As New DataView(DS.Tables("counties"), str, "SORT = DIVORCED", DataViewRowState.CurrentRows)
Me.DGDetails.DataSource = "" 'Me.DGDetails is the current datagrid. This line is intended to empty the datagrid.
Me.DGDetails.DataSource = mydataview ' This line should fill the datagrid with the filtered results of the mydataview instance.
End Sub
****************************************
I would welcome a link to an example that uses this method, or a parameterized query to accomplish the same thing. I am coding in VB2010 and haven't upgraded the datagrid to a datagridview for several reasons not relevant here. Thanks for any help.
nibagadiya
Member
45 Points
22 Posts
Re: Update Datagrid with DataView - VB2010, ASP.NET 4
May 01, 2012 06:36 PM|LINK
You need to bind data after Ading new data in datasource.
like this:
zeitguy
0 Points
3 Posts
Re: Update Datagrid with DataView - VB2010, ASP.NET 4
May 01, 2012 07:31 PM|LINK
You need to bind data after Ading new data in datasource.
like this:
I am not using the DataGridView because I started this project years ago and have too much code depending on the DataGrid to change it very easily.
Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: Update Datagrid with DataView - VB2010, ASP.NET 4
May 03, 2012 08:55 AM|LINK
Hi,
What you ask is winform control, this is ASP.NET forum for web controls. You can post the question to MSDN forum:
http://social.msdn.microsoft.com/Forums/en-US/category/netdevelopment
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework