This error occurs in my WebDataGrid when I edit cells after a postback. The first time works okay, but the second time throws this error:
The string parameter 'key' cannot be null or empty.
Parameter name: key
I have attached a simple project that demonstrates this. You'll see that there is only one row in the grid, and it is not null or empty.
How to reproduce:
1. Run the attached app
2. Enter text into the second column
3. Click Submit
4. Repeat steps #2 and 3 (you will see the error)
Hello Ray,
I'd be glad to assist you if you are facing any other issues.
This grid is so fragile I don't know what to do anymore.
This is not a bug. The grid should be bound to a consistent data source. The PrimaryKey of the DataTable you are binding to is different on each page load, so the update can’t be completed. Also, I would suggest you to bind on PageLoad and in case you are using DataViewState, set the data source only on the first load.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
WebDataGrid1.DataSource = FillDataSet;
}
WebDataGrid1.DataBind();
Let me know if you have further questions.
I think this is a bug. Please escalate it to your developers for review.
There is no logical reason why removing ClearDataSource should be required. In fact, when I remove it from my app, it causes other bugs to appear. This grid needs to be more robust.
Hi Ray,
Thank you for the sample. I have reviewed it and it seems that the issue is caused by the call to ClearDataSource method. Remove this line and it should be working.
Let me know if you have any further questions.