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

C# doubt in data grid

P: 2
I have a TAB where a data grid gets displayed. I want to access the elements of the datagrid.
but i'm getting the following error. "Data cannot be read from a DataGrid which is not bound to a DataTable".

But the thing is, in the TAB where the data grid gets displayed, i have kept a button (btnTestCase), and i'm able to access the data grid values from this method.

Can u help me in resolving this issue. i need to access the values of the datagrid in the method "mnuTestGen_Click()" i.e after the method "Test()" which contains code for populating values in the data grid.

Here is the code of the two methods,

private void mnuTestGen_Click(object sender, System.EventArgs e) // by pragadheesh
Test(); //after this data grid gets loaded in the TAB
MessageBox.Show(dataGrid2[0,4].ToString()); //error here "Data cannot be read from a DataGrid which is not bound to a DataTable."

private void btnTestCase_Click(object sender, EventArgs e)
MessageBox.Show(dataGrid2[0,4].ToString()); //NO error here

Thanks in advance.

Feb 25 '09 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.