Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datagrid BIG RED X

Status
Not open for further replies.

shades44

Programmer
Jun 14, 2004
25
CA
hello,

i have a button, a datagrid and a textbox
this is my code:

private void button1_Click(object sender, System.EventArgs e)
{

DataTable dt = getDevices();//returns a datatable
dtgEvents.DataSource = dt;
dtgEvents.Refresh();

}

my getDevices() method reads the value in the textbox and returns a datatable with the results from the database.

let's say when i have "server" in my textbox and i click on 'button1' the datatable returned has sound data in it and my datagrid gets populated correctly. when i have "client" in my textbox the datatable returned is corrupt for some reason and i get a big red X in my datagrid.

i've noticed that once the red X is there it's there to stay.. for example if i now type "server" in my textbox again and click on the button to rebind the datagrid it doesnt work.. how do i recover from the red X? it seems that once a datagrid gets the red X it's useless and cant be refreshed at runtime

anyone got any ideas?
shady
 
Put a breakpoint on the line where you set the datasource to the table and do a QuickWatch on dt. Have a look through it to make sure that the data is fine.

It may be that it's your getDevices method that's the problem, rather than the DataGrid. If it's returning dodgy data after the first read then that would throw up a problem.

You might want to try using

Code:
dtgEvents.TableStyles.Clear();

before you assign the datasource; it might solve your problem and it might not.

Alternatively there are lots of discussions about the same problem here:


Nelviticus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top