SonicBoomAu Posted April 12, 2005 Posted April 12, 2005 Hi All, I am currently having a problem identifying the number of columns and rows in a datagrid. He is my code: Dim rowCount As Integer Dim colCount As Integer Try rowCount = CType(Me.DataGrid1.DataSource, DataView).Table.Rows.Count colCount = CType(Me.DataGrid1.DataSource, DataView).Table.Columns.Count Catch ex As Exception MessageBox.Show(ex.Message) End Try The error I am receiving is: "Specified cast is not set" on "rowCount = CType(Me.DataGrid1.DataSource, DataView).Table.Rows.Count" line of code. Is this the correct way to be doing this? Any help will be greatly appreciated. Quote Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -- Rick Cook, The Wizardry Compiled
SonicBoomAu Posted April 13, 2005 Author Posted April 13, 2005 Have found answer. 'Need to find out the number of Rows & Columns in Datagrid Dim row As Integer Dim col As Integer Dim rowCount As Integer Dim colCount As Integer Try rowCount = CType(Me.DataGrid1.DataSource, DataViewManager).DataSet. _ Tables("StaticAssets").DefaultView.Table.Rows.Count colCount = CType(Me.DataGrid1.DataSource, DataViewManager).DataSet. _ Tables("StaticAssets").DefaultView.Table.Columns.Count Catch ex As Exception MessageBox.Show(ex.Message) End Try Quote Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -- Rick Cook, The Wizardry Compiled
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.