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
close icon

GridGroupingControl new row

Hi,

I am using a GridGroupingControl with a typed DataTable as datasource. This typed datatable has a primary key which is a integer that increments automaticly and is bound in de control's Init-event.

This datatable is stored in the session, because I don't want it to be static. Although I tried my thing with a statis datatable and that doesn't work either.

I can edit existing rows and my datatable is updated with the new data, so that works fine. But when I edit the new row and leave the row or accept the changes using the buttonbar an Exception is thrown: Object reference not set to an instance of an object.

at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Syncfusion.Web.UI.WebControls.CallbackControlEnabler.ViewStateToLoad(Object state)
at Syncfusion.Web.UI.WebControls.CallbackControlEnabler.LoadViewState(Object savedState)
at Syncfusion.Web.UI.WebControls.CallbackDataBoundControl.LoadViewState(Object savedState)
at Syncfusion.Web.UI.WebControls.Grid.Grouping.GridGroupingControl.LoadViewState(Object savedState)
at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)
at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)
at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)
at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)
at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at System.Web.UI.ControlCollection.Add(Control child)
at Module.Page_Load(Object sender, EventArgs e) in d:\Projects\MyProject\Module.aspx.cs:line 44
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

So, data is bound in Init and Primary Key is set, but I still get this exception...

Bart

6 Replies

GB Gokul B Syncfusion Team November 23, 2006 11:54 PM UTC

Hi Bart,

Sorry for delay in getting back to you.

We thought viewstate is not maintained in your scenario, but still we are not sure. Although we tried to reproduce the issue as you mentioned but we couldn't. so could you please update us with the sample which causes this issue. It will help us to come up with solutions.

Thanks for using Syncfusion products.

regards,
B.Gokulkumar


BC Bart Coppens November 24, 2006 08:00 AM UTC

Here it is (I had to cut it out of the rest of the code, so I had to hack some things). So I can edit the two rows and they are updated in the datasource behind, but I can't add a new row.

Thanx

Demo11.zip


AD Administrator Syncfusion Team November 25, 2006 12:31 AM UTC

Hi Bart,

We are looking in to this and will update you as soon as possible.

regards,
Siva


GB Gokul B Syncfusion Team November 27, 2006 11:46 PM UTC

Hi Bart,

As you mentioned, we could reproduce this issue. So we need to look bit more for some workaround and let you know in another "2" days.

Thanks for using Syncfusion products.

regards,
B.Gokulkumar


AD Administrator Syncfusion Team November 29, 2006 06:38 PM UTC

Hi Bart,

We checked for a while, but still we are not sure why this error occurs. so we have attached a sample which will bind the grid to datasets with addnew row functionality. Please download the sample by clicking the link below, and do let us know if you are able to reproduce the error in this sample

Bindingtodataset_forum52199.zip

I think, you might have missed to give adding new record feature for DataSet schema in your application, but not sure this causes the issue.

Thanks for using Syncfusion products.

regards,
B.Gokulkumar


BC Bart Coppens November 30, 2006 08:52 AM UTC

Hi B,

Thanks to your example I had I 'brain wave' :-). What went wrong in my code is that I bound a instance of a typed DataTable to the datasource of the grid. Your control expects a DataSet. My error occurs when no dataset is defined.

So, when I have a DataSet called MyTypedDataSet with a table in it called MyTypedDataTable I can't do this (adding won't work):

MyTypedDataSet.MyTypedDataTable dtInstance = new MyTypedDataSet.MyTypedDataTable();
// Fill table
grid.DataSource = dtInstance;

I have to do it like this:
MyTypedDataSet dsInstance = new MyTypedDataSet();
// Fill table
grid.DataSource = dsInstance;
grid.DataMember = "MyTypedDataTable";

Apperently, if the datasource is a datatable, you are doing something with the instance.DataSet, but that can be null...

Bart

Loader.
Live Chat Icon For mobile
Up arrow icon