Welcome to the Xceed Community | Help
Community Search  

Empty grid after databinding..

Sort Posts: Previous Next
  •  01-03-2008, 10:18 PM Post no. 3208

    Empty grid after databinding..

    Out of the blue the grid no longer binds correctly. Here is sample code:

    With Grid
    .BeginInit()
    .DataSource = dt
    .EndInit()
    End With

    This code has worked fine for a while. Now all of the sudden my grid shows 0 datarows, however, if I set a breakpoint right after end init I see the datatable (dt) has rows, but the xceed grid datarows is empty.

    What is even more strange is that I put a regular DataGridView on the form and bound to that right before the BeginInit of the xceed grid binding and for some reason that makes it work. I have no clue why binding to something else before binding to the xceed grid would make a difference but it does.

    Any suggestions would be great.
  •  01-04-2008, 1:42 PM Post no. 3209 in reply to 3208

    Re: Empty grid after databinding..

    I tried pretty much the same code as you and it worked fine.

    <code>
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    With GridControl1
    .BeginInit()
    .DataSource = GetTable()
    .EndInit()
    End With

    End Sub

    Private Function GetTable() As DataTable
    'Create a DataTable
    Dim dt As New DataTable()
    Dim dcId As New DataColumn()
    dcId.ColumnName = "ComplexId"
    dcId.DataType = System.Type.[GetType]("System.Int64")
    dt.Columns.Add(dcId)

    Dim dcName As New DataColumn()
    dcName.ColumnName = "ComplexName"
    dcName.DataType = System.Type.[GetType]("System.String")
    dt.Columns.Add(dcName)
    For i As Integer = 0 To 49

    Dim row As System.Data.DataRow = dt.NewRow()
    row("ComplexId") = i
    row("ComplexName") = i.ToString() + "%"
    dt.Rows.Add(row)
    Next

    Return dt
    End Function
    </code>
    Charles Bérubé-Rémillard
    Technical Support
    Xceed Software Inc.
  •  01-04-2008, 3:13 PM Post no. 3210 in reply to 3208

    Re: Empty grid after databinding..

    Yes, well I can make a simple app like that and it works. For some reason with all of the code I have something makes it not work. I was wondering if you had any ideas. I can make it work perfectly fine if i add the following line of code:

    dt = GetTable()

    DataGridView1.DataSource = dt
    With XceedGrid
    .BeginInit()
    .DataSource = dt
    .EndInit()
    End With

    For some reason binding it to a datagridview before binding it to the xceed grid does something to the datatable or some action that resolves the problem. Is there anything that might need changed on my datatable?
  •  01-08-2008, 12:02 PM Post no. 3211 in reply to 3210

    Re: Empty grid after databinding..

    The issue could be related to the DataMember not being explicitly set at this point.

    Instead of using the DataSource property to set the source, you could use the SetDataBinding method. It will directly set both the DataSource and the DataMember.

    Charles Bérubé-Rémillard
    Technical Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.