Error when setting datasource

I get the error "no value at index -1" when I set the datasource to a dataset with no rows int it at run time. If I set the datasource at design time and the dataset has no rows I get no error. What gives? How do I get around this?

1 Reply

AD Administrator Syncfusion Team November 8, 2004 03:35 PM UTC

I don''t see a dropping a GridDataBoundGrid on a Form and using this formload to populate it with a datatable with no rows using 2.1.0.9.
private void Form1_Load(object sender, System.EventArgs e)
{
	DataTable dt = new DataTable("MyTable");
	int nCols = 4;
	for(int i = 0; i < nCols; i++)
	this.gridDataBoundGrid1.EnableAddNew = false;
	this.gridDataBoundGrid1.DataSource = dt;
}
Now if you are trying to reset data into an existing grid, then you may want to try calling: grid.CurrentCell.EndEdit(); grid.Binder.EndEdit(); You can also try this code to make sure there is no currentcell when you reset the data. grid.CurrentCell.MoveTo(-1, -1); grid.Binder.CurrentPosition = -1; If you can post a sample showing the problem, we can try to suggest something.

Loader.
Up arrow icon