We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Sorry Another Question

I stored a datatable in an arraylist. I take that arraylist and pass the stored datatable to a new instance of a datatable and then set a databounddatagrid''s data source to that datatable. If i pass it to a databound grid that I created through the designer I can see it fine and i can access the items within it. However if I pass it to a databound grid i created in the code then i cant access the items within it i get blank values. Also which I find very pelicuar I created both grids and I passed the datatable to the programmed databound grid and then set the designer databound grid to the datasource of the programmed databound grid and I can get fine results biut I still cant get values for the programmed datagrid what gives? Here is the code: Private Sub ITS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ITS.Click Dim gdbc_DataBoundGrid As New Syncfusion.Windows.Forms.Grid.GridDataBoundGrid Dim dt_DataTable As New DataTable("CC") dt_DataTable = al_StudbookID.Item(0) ''programmed databound grid gdbc_DataBoundGrid.DataSource = dt_DataTable ''databound grid in the designer GridDataBoundGrid1.DataSource = gdbc_DataBoundGrid.DataSource ''this msgbox gives me a blank value MsgBox(gdbc_DataBoundGrid.Item(1, 1).Text()) ''this msgbox gives me a proper value MsgBox(GridDataBoundGrid1.Item(1, 1).Text) End Sub

1 Reply

AD Administrator Syncfusion Team January 27, 2005 03:31 PM UTC

A control does not have its BindingContext member set until it is parented which usually happens when you add the control to its parent''s COntrols.Collection. In your code, there is no Me.Controls.Add(gdbc_DataBoundGrid) so the grid does not have a parent and hence gdbc_DataBoundGrid.BindingContext is Nothing. So, one thing you can try is to explicitly create the grid''s BindingContext before you try to use the grid in a bound manner. gdbc_DataBoundGrid.BindingContext = new BindingContext() (Note that Control.BindingContext is marked as an ''advanced'' property in teh VB''s editor, so you will not see it in intellisense unless you have explicitly enabled this in your VisStu properties.) If that does not work, then you can add the grid to the forms'' Controls collection and I suspect that will make things go through OK. gdbc_DataBoundGrid.Visible = True Me.Controls.Add(gdbc_DataBoundGrid)

Loader.
Live Chat Icon For mobile
Up arrow icon