changing datagrid with rowfilter

sdcowboy

New member
Joined
Sep 1, 2005
Messages
2
Programming Experience
10+
Thanks in advance. This has been covered before, but I can't find it.

I've got a datagrid that is populated by a dataset. On the initial page load a subroutine is called to set the rowfilter property, set the datagrid's datasource and bind the data. This works fine on the page load and the page displays all of the filtered dataset's rows. The problem occurs when a button click routine changes a textbox value and calls the same subroutine to update the rowfilter property, reset the datasource and rebind the datagrid. The page refreshes with a datagrid header, but no rows. (Yes, there are rows in the dataset that match the rowfilter) (The connection, adapter, dataset and datagrid were all created at design time)

Code for the page load, button click and datagrid binding subroutine below:

PrivateSub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
If Not (Me.IsPostBack) Then
daMtg_Inventory.Fill(dsMtgMain1)
updateMtgMain()
EndIf
EndSub


PrivateSub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
txtSqlFilter.Text = "'R'"
updateMtgMain()
EndSub


Sub
updateMtgMain()
If txtSqlFilter.Text = "'R'" Then
dsMtgMain1.Tables("MTG_Main").DefaultView.RowFilter = "Color = 'R'"
Else
dsMtgMain1.Tables("MTG_Main").DefaultView.RowFilter = "Color = 'G'"
EndIf
dgMtgMain.DataSource = dsMtgMain1.Tables("MTG_Main").DefaultView
dgMtgMain.DataBind()
EndSub


What am I missing that I can't find in the online help?


Regards, Slim

 
Back
Top