PDA

Click to See Complete Forum and Search --> : problem when databinding datagrid at runtime


Cliff Burton
Sep 5th, 2002, 10:48 AM
I have a datagrid that I bind at run time to different datasets depending on what options the users select. When the user makes the selection, the grid does not appear -- there is just a plus sign +. When the user clicks on the + sign, the word Table appears, and when the user clicks on the word table, THEN the datagrid appears. There is a method associated with datagrid objects called 'Expand()' but that didn't seem to do anything.

Here's the code:

' in #Region
Friend WithEvents dgUIDCORequests As System.Windows.Forms.DataGrid

Dim conDatabase As SqlConnection = New SqlConnection(SQL_CONNECTION_STRING)
Dim cmdSQL As SqlCommand
Dim ds As DataSet
Dim adpUIDCORequests As SqlDataAdapter = New SqlDataAdapter()

cmdSQL = New SqlCommand(pstrSqlCommand, conDatabase)
conDatabase.Open()
adpUIDCORequests.SelectCommand = cmdSQL
ds = New DataSet(strStatusOfRequests & RequestType.SelectedNode.FullPath.ToString)
adpUIDCORequests.Fill(ds)
dgUIDCORequests.SetDataBinding(ds, "")
dgUIDCORequests.ReadOnly = True
dgUIDCORequests.Expand(-1)
dgUIDCORequests.ParentRowsVisible = True
dgUIDCORequests.Show()
dgUIDCORequests.PreferredColumnWidth = 85

conDatabase.Close()