databindings to datagrid

How do I bind a datarow array (mydatarow()) to a datagrid (mydatagrid) at run time. Something like:

mydatagrid.databinding ...




Answer this question

databindings to datagrid

  • Mr_Mojoman

    I tried, but xdatagrid does not bring Datasource property, only Databindings and others.

    BTW, your code looks similar to mine except that you are using the RowFilter method whereas I am using the Select method.

    You know, even mine was working except how to refresh (or reload)the datagrid to show the selected records only. So, can someone tell how to refresh datagrid.

    Thanx for keeping up the fire.

    BTW, I am using VB 2003.



  • Pavel Sich

    Hi

    I think this will work for you.

    Dim filterVal As String = TextBox1.Text()
    Dim filterFld As String = ComboBox1.Text
    Dim filterExpr As String = filterFld & " like '" & filterVal & "%'"

    Dim xdatagrid As New DataGrid

    xdatagrid.DataSource = Dataset11.Tables("MyTable").DefaultView

    Dataset11.Tables("MyTable").DefaultView.RowFilter = filterExpr



  • questron

    HI Atin

    I think Better you can create a datatable, Put all the Rows in the DataTable.

    Then you Can Assaign DataTable to DataGrid as usual.



  • nabeelfarid

    But the datarow() I have is a result of a table select method. So it is a subset of the dataset I have on the datagrid. Something like:


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim filterVal As String = TextBox1.Text()
    Dim filterFld As String = ComboBox1.Text
    Dim filterExpr As String = filterFld & " like '" & filterVal & "%'"
    Dim foundRows() As DataRow = Dataset11.Tables _
    ("myTable").Select (filterExpr)

    'Now how do I fill the datagrid with foundrows(), which is a subset of
    'Dataset11. Something like this, but I don't know.
    Dim
    xdatagrid As New DataGrid
    xdatagrid....

    End Sub



  • databindings to datagrid