By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,742 Members | 1,227 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,742 IT Pros & Developers. It's quick & easy.

dynamically created datagridview columns unset even after data source set

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.