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

Problem rebind GridGroupingControl

Hi,
i have a little problem. I have bound a SqlDataSource to a GridGroupingControl. The SqlDataSource depends from same parameters i have stored as Session variables. When i load the page and the DataBind() at the Page_Init works fine. Now i change some of the session variables and try
this.GridGroupingControl1.DataBind(); but the grid dosen´t reflect the new data. When i reload the page with the refresh button at the browser, the new data appears (now DataBind is called from Page_Init !). Is´t not possible to call DataBind() other then in Page_Init ?
Thanks for help
regards
Kai

13 Replies

GB Gokul B Syncfusion Team January 9, 2007 04:40 PM UTC

Hi Kai,

We noticed that changes made in the session state was not get changed in the page_init. Instead We can get the session state changes only in page_load.So we made some investigation and found a workaround to bind the grid in other than page_load event.

Here with we attached a sample to overcome the issue you are encountering.

Forum_54421.zip

Here is the description of the sample.

* We bind the GridGroup using OleDB. you can use either any .net datasource control.
* Here we populate the GridGroup based on the value entered in the textbox(Ex:enter values like 1 or 5).
* We used session variable "SupplierID" to hold the values enter in the textbox, which is used to bind the grid once again in Page_Load event after session state value get changed.

please Let us know if you cannot use this workaround in your scenario for any reason.

Thanks for using Syncfusion product.

Regards,
Gokulkumar.B


KA Kai Abesser January 15, 2007 10:16 AM UTC

sorry Gokulkumar, but your sample dosen´t help ... but i found an other way for my problem with rebinding in the page_load event.

But now i have a new problem:
Is there a way, to get the selection event in a multi selection grid other than the "SelectedRecordsChanged" event with PostBackOnFocusedChanged = False ? (maybe a CallBack Skript ?) My problem is, that the page_load event must now rebind the grid for some other functions, but now it destroyes the multiselection !

thank you for your assistance.
regards
Kai


KA Kai Abesser January 16, 2007 08:58 AM UTC

long time no anwers ... i think, i will try other grid products with more support !!!!!!


GB Gokul B Syncfusion Team January 16, 2007 03:52 PM UTC

Hi Kai,

We apologize for the delay in getting back to you.

Since we are all on vacation for past 2 days, so we couldn't update you at the earliest. We are currently looking into this and update you later today.

Thanks for using Syncfusion products.

Regards,
Gokulkumar.B



GB Gokul B Syncfusion Team January 16, 2007 11:48 PM UTC

Hi Kai,

Here are my answers for the problems that you are facing.

* How do we persist the selected records(i.e when GridGroup Selection mode is set to "MulitSimple/MultiExtended") even when the GridGroup is rebind on page_load?
Call the below code snippet after the Grid had rebind in page_load event

//Iterates through the collection of SelectedRecords in GridGroup control.
foreach (SelectedRecord sel in this.GridGroupingControl1.Table.SelectedRecords)
{
Record r = sel.Record;
//Marks the Current record as selected
r.SetSelected(true);
//Makes the record as Current Record
r.SetCurrent();
}
In the CurrentRecordContextChange event call the below code to add the selected record in selected record collection

//Gets the current Record
Record r = this.GridGroupingControl1.Table.CurrentRecord;
//Creates the Selected record entry
selectedrecord = new SelectedRecord(r);

Else you can save the values of the selected record either in ArrayList and mark the record as selected based on the ArrayList values in Page_load event

Let us know if this helps.

Thanks for using Syncfusion products.

Regards,
Gokulkumar.B




KA Kai Abesser January 17, 2007 09:16 AM UTC

Hi Gokulkumar,
i also had the same idea and tried this construction, but if i call
foreach (SelectedRecord sel in this.GridGroupingControl1.Table.SelectedRecords)
in page_load after rebind Grid SelectedRecords is allways 'null' ... !
Maybe i should save the selection with a clientside skript ?
For this i tried your example at
http://www.syncfusion.com/support/Forums/message.aspx?MessageID=50691

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;

}

but i get allways a loaderror on page: "__EssentialGridCollection is no object or undefined". I´m a newbie on javaskript, so i don´t know how to define obejcts and i don´t find any useful dokumentation ...

thank you for your assistance.
regards
Kai




GB Gokul B Syncfusion Team January 17, 2007 09:06 PM UTC

Hi Kai,

For your kind information,"Undefined _EssentialGridCollection Object" error occurs only when we fail to call the created object.Please have a look at the below code snippet to create/define a object using Javascript.

function CreateObject()
{
var gridObj = __EssentialGridCollection.Get("GridGroupingControl1");
// the grids id
gridObj.onselectedrowchanged =OnSelectedRowChanged;
}
call the above funtion below the form tag in aspx file.Then try
function OnSelectedRowChanged(gridobj,tr)
{
//Here your code to save the selection

}

Instead of saving the selection in client side, you can also save the values of the selection in CurrentRecordContextChange event either using ArrayList like shown below and mark the record as selected based on the ArrayList values in Page_load event

if (e.Record != null)
{
Record rec = (Record)e.Record;
string str = rec.GetValue("EmployeeID").ToString();
//Here arr denotes the Array List
arr.Add(str);
}

Let us know if this helps and do let us know if you need more information.

Thanks for using Syncfusion products.

Regards,
Gokulkumar.B


KA Kai Abesser January 18, 2007 06:32 AM UTC

Hi Gokulkumar,
still problems:
1. Clientside: i don´t understand how to install the eventhandler. This is my skript section:



who is calling CreateObject() ??? My evensthandler is never fired ...

2. Serverside: how can i resolve the multi selection in CurrentRecordContextChange event ? How can i see the difference between a single selection or a multi selection ?

Thanks for your help
regards
Kai



KA Kai Abesser January 18, 2007 06:46 AM UTC

skript snippet is gone away ... :-)

;


GB Gokul B Syncfusion Team January 18, 2007 08:42 PM UTC

Hi Kai,

Here are my answers for your query.

1) You can create and call the created object using below code snippet.
.
.
$script type="text/javascript">
var SelectRowId
function createObject()
{
var gridObj = __EssentialGridCollection.Get("GridGroupingControl1");
// below code Will invoke the OnSelectedrowChanged eventhandler.
gridObj.onselectedrowchanged =OnSelectedRowChanged;
}
function OnSelectedRowChanged(gridobj,tr)
{
//Here your code to save the selection

}
$/script>
.
.
$/form>
$script>
createObject()
$/script>

However we have attached one sample Aspx Page for your further reference.

2)We can obtain the differences between single selection and multiselection by adding some counter variable in CurrentRecordContextChange event. As we already metioned use the ArrayList to save the selected values, It makes easier to differentitate between single and multiselection by Array Count.

Let us know if you need more help.

Thanks for using Syncfusion products.

Regards,
Gokulkumar.B


KA Kai Abesser January 19, 2007 01:00 PM UTC

Hi Gokulkumar,
thanks for the snippet, now the event will be fired till i change the grid page ... after i change to the next grid page, the eventhandler is not longer called ! Any idea ?
regards
Kai


GB Gokul B Syncfusion Team January 19, 2007 08:10 PM UTC

Hi Kai,

To achieve the behavior as you expected you need to set "EnableCallbacks" properties as "False". This, creates the object on each subsequent postbacks(i.e Nextpage in this scenario).

Let us know if you need more help.

Thanks for using Syncfusion products.

Regards,
Gokulkumar.B


GB Gokul B Syncfusion Team January 22, 2007 09:13 PM UTC

Hi Kai,

Instead of setting "EnableCallback" as false, you can also use AfterCallbackResponseProcessedScript, which specifies the script that will be executed after the callback result gets processed. Please have a look at the below code snippet.

//Excutes the script after callback is Processed (i.e create the object in this scenario).
$sfwg:GridGroupingControl ID="GridGroupingControl1" runat="server" PostBackOnFocusedChanged=false AfterCallbackResponseProcessedScript="createObject()">
$/sfwg:GridGroupingControl>

Let us know if you need any other assistance.

Regards,
Gokulkumar.B


Loader.
Live Chat Icon For mobile
Up arrow icon