Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataView to dataGrid help

Status
Not open for further replies.

mwfrancois

Technical User
Dec 20, 2002
4
US
Newbie here with hopefully a simple issue. I have searched and not found what I understand to be helpful. My problem is I am not getting any records returned to my datagrid. The field headings show up but no records. Any suggestions? Here is my code:

Private Sub SetUpGrid()

'Dimension dvVBCreditCard DataView object
Dim dvVBCreditCard As DataView

'Instantiate New DataView with data from table "VBCreditcard" in the dsVBCreditCard1 DataSet
dvVBCreditCard = New DataView(dsVBCreditCard1.Tables("VBCreditcard"))

'Filter Dataview by string in txtLname box
dvVBCreditCard.RowFilter = "LName = '" & txtLname.Text & "'"

'Set DataGrid equal to DataView
dgVBCreditCard.DataSource = dvVBCreditCard

End Sub
 
You need to call .Databind.

Code:
Private Sub SetUpGrid()

        'Dimension dvVBCreditCard DataView object
        Dim dvVBCreditCard As DataView

        'Instantiate New DataView with data from table "VBCreditcard" in the dsVBCreditCard1 DataSet
        dvVBCreditCard = New DataView(dsVBCreditCard1.Tables("VBCreditcard"))

        'Filter Dataview by string in txtLname box 
        dvVBCreditCard.RowFilter = "LName = '" & txtLname.Text & "'"

        'Set DataGrid equal to DataView
        dgVBCreditCard.DataSource = dvVBCreditCard

        [b]'Bind DataGrid
        dgVBCreditCard.DataBind[/b]

    End Sub
 
Mike555,
Thank you for your assistance. Unfortunately, I was unable to get the DataGrid records to show after adding the dgVBCreditCard.DataBind call. I received an error "Property access must assign to the property or use its value."
Do you have any other suggestions? Or, am I not understanding your first bit of help?

Here is the updated code:

'Dimension dvVBCreditCard DataView object
Dim dvVBCreditCard As DataView

'Instantiate New DataView with data from table "VBCreditcard" in the dsVBCreditCard1 DataSet
dvVBCreditCard = New DataView(dsVBCreditCard1.Tables("VBCreditcard"))

'Filter Dataview by string in txtLname box
dvVBCreditCard.RowFilter = "LName = '" & txtLname.Text & "'"

'Set DataGrid equal to DataView
dgVBCreditCard.DataSource = dvVBCreditCard

'Bind DataGrid
dgVBCreditCard.DataBindings()

 
I don't see where you are filling the dsVBCreditCard1 dataset. Does this occur before SetUpDataGrid() is called?
 
try using a Like Clause
Code:
dvVBCreditCard.RowFilter = "LName LIKE '" & txtLname.Text.Trim & "*'"


Sweep
...if it works dont f*** with it
...if its f****ed blame someone else
...if its your fault that its f***ed, say and admit nothing.
 
'Bind DataGrid
dgVBCreditCard.DataBind

is only neccesary for the ASP.NET datagrid.

not for windows forms.

And what happens if you leave out the rowfilter?

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top