469,883 Members | 1,232 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,883 developers. It's quick & easy.

dynamically created datagridview columns unset even after data source set

In the following code I retrieve data from a stored procedure that
returns multiple resultsets (the results of the stored procedure have
been stored in a datareader called reader). On each iteration a tab
page is added to a tab control and a datagridview is created on that
the tab page. In the first iteration I can set all the values with no
problems, however on the next iteration, even though there is
definitely data in the data source, no columns are created and thusly
my application crashes when I attempt to access the columns property.
Can anyone help ???

Do
While Not reader.IsClosed AndAlso reader.HasRows
reader.Read()
dtDetails = New
jeopardyDataSet.Aggregate_Calculated_Port_StatsDat aTable
Me.tctlDetails.TabPages.Add(reader("MSC_NAME"))
tabDetails =
tctlDetails.TabPages(tctlDetails.TabPages.Count - 1)
dgvDetails = New DataGridView()
dgvDetails.Location = New System.Drawing.Point(80,
80)
dgvDetails.Width = 100
dgvDetails.Visible = True
dtDetails.Load(reader)
dgvDetails.AllowUserToAddRows = False
dgvDetails.AllowUserToDeleteRows = False
dgvDetails.DataSource = dtDetails
tabDetails.Controls.Add(dgvDetails)
dgvDetails.Dock = DockStyle.Fill
dgvDetails.Columns("MSC_KEY").Visible = False
'dgvDetails.Columns("MSC_NAME").Visible = False
End While
Loop While Not reader.IsClosed AndAlso reader.NextResult

Mar 28 '06 #1
0 1028

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Rob | last post: by
1 post views Thread by mark carew | last post: by
1 post views Thread by DBC User | last post: by
7 posts views Thread by Mitchell S. Honnert | last post: by
8 posts views Thread by Brian Pelton | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.