We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Error when setting datasource

Thread ID:





21344 Nov 8,2004 01:49 PM UTC Nov 8,2004 03:35 PM UTC WinForms 1
Tags: GridControl
Chris Thompson
Asked On November 8, 2004 01:49 PM UTC

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?

Administrator [Syncfusion]
Replied On 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
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.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon