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

Grid post backs

I am using the ASP.NET GridGroupingControl (version 4.301.0.32) and constructing a System.Data.DataTable programatically and assigning this as the DataSource. I have managed to setup the grid columns for filtering and sorting, but when I select an option in the filter drop down or click on a column, the page seems to post back to the server and then I get a System.Web.HttpUnhandledException thrown. Is their something I need to do? Looking at the example everything seems to occur automatically.

Can someone help please.

Cheers,

Michael

7 Replies

AD Administrator Syncfusion Team October 17, 2006 12:56 PM UTC

Hi Michael,

As mentioned in our Users Guide, Essential Grid expects the data source to include a primary key column. Make sure to include a PrimaryKeyColumn to the TableDescriptor before calling DataBind(), as shown below.

Here is an example of how the WebPage's Init would typically look in an Application using the GridControl.


[C#]

private void Page_Init(object sender, System.EventArgs e)

{
//Add a primary key to the PrimaryKeyColumns collection

GridTableDescriptor mainTD = this.GridGroupingControl.TableDescriptor;

// CustomerID could be a field name in the datasource

mainTD.PrimaryKeyColumns.Add("CustomerID");

//Call DataBind

this.GridGroupingControl.DataBind();

}

Let us know if this helps.

Thanks,
A.Sivakumar


MD Michael Digman October 17, 2006 04:11 PM UTC

Thanks for the reply. I am setting the primary key and binding the control to the data.

The only difference being that I have set the primary key to a column that is hidden. Could this be the issue.

I have managed to extract the exception if it helps (see attachment).

Cheers,

Michael

exception8.zip


AD Administrator Syncfusion Team October 17, 2006 05:13 PM UTC

Hi Michael,

I assume you are binding the grid in Page's Load event, whereas our grid requires to be binded in Page's Init event. Could you please make sure this is taken care in your sample?

We apologize for any inconvenience caused.

Thanks,
A.Sivakumar


MD Michael Digman October 18, 2006 03:29 PM UTC

Thanks, I've managed to get past the exceptions by making sure the data is bound to the control in the pages Init event.

Do I have to rebind the data to the control everytime I post back to the server? This seems like a big overhead as the data source I'm using is not directly tide to a database and won't change that often.

Another question I have revolves around the use of client side javascript. How do I call a javascript function when a row is selected on the grid?

Cheers,

Michael


AD Administrator Syncfusion Team October 18, 2006 07:58 PM UTC

Hi Michael,

Yes, you have to rebind the control every time, this is because we avoid caching of data at client side , but because of a lot of requests, we already started implementing DataCaching and so you will not do this once this feature, gets implemented. This feature is almost completed and will be available by the end of this month.

When a row is selected on the client side 'Onselectedrowchanged' client side event will be triggered. You can use the following code to do this

var gridObj = __EssentialGridCollection.Get("GridGroupingControl1");
// the grids id

gridObj.onselectedrowchanged =OnSelectedRowChanged;

function OnSelectedRowChanged(gridobj,tr)
{
//tr will give you the selected row element.
var SelRowId=tr.id;

}

Let us know if you need more info.

Thanks,
A.Sivakumar


MD Michael Digman October 19, 2006 12:35 PM UTC

When the OnSelectedRowChanged() function is called is there a simple way of working out if it is a select or a deselect?

Cheers,

Michael


AD Administrator Syncfusion Team October 19, 2006 11:07 PM UTC

Hi Michael,

We tried for a while on this, but couldn't see some easy way to do this. However, we will check more about this and will let you know later.

Thankyou for using syncfusion products.

Thanks,
A.Sivakumar

Loader.
Live Chat Icon For mobile
Up arrow icon