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

GridGroupingControl View state

Hello,

I am using the GridGroupingControl in a page and it has a column that contains CheckBox (Template Column).

When I click on it I would like to keep the previous state of my GroupGroupingControl and also for the checkboxes in the column, and then seeing the same data.

Thank you for your help.

16 Replies

RA Ramu Syncfusion Team August 29, 2006 09:28 PM UTC

Hi Ahmed,

Here is the sample that holds the previous state of Checkbox control and also the checkbox of the GridGroupingControl. I have added an unbound template column with check box in it. CheckedChanged event is handled to keep track of the checked status of the check box in the GridGroupingControl, you can view this in the information label by clicking the update info button.

TemplatedCheckBox_2005


Note: I have used Categories table from NWIND.MDB which is already pointing to the syncfusion virtual directory. so If you have syncfusion version installed on your machine and the sample is using the ''Default IIS'' you no need to change anything for this sample to run , else you will have to change the ''Datafile of the Access datasource control'' (this is the case for running the above sample in file system)


Please let me know I you have any queries.

Thanks,
Ramu.K


AM Ahmed Mostafa September 5, 2006 09:43 AM UTC

The Code goes will
but I use some view state variables to bind the grid

so I must bind it in the page load event
when I bind it in the page load event The view state of checked box volatile


SI Sivakumar Syncfusion Team September 5, 2006 03:57 PM UTC

Hi Ahmed,

As specified in our Essential Grid USer''s Guide (under EssentialGrid->ASP.NET->UsingGridgroupingControl->SettingupDataBinding)
Our grid need to specify the appropriate DataSource and call DataBind() in the Web Form''s Page_Init() event,
Calling DataBind in Page_Load could result in unexpected behavior.


Based on the requests from customers, we already started fixing this and within another one month this will be fixed
and the user will be able to bind the grid in any event.

However, we do have some workarounds to overcome this situation based on the scenario''s.
We started creating a sample here based on your requirements mentioned above, we willupdate you with more info here as soon as
possible.

sorry for the inconvenience caused.

Regards,
A.Sivakumar


SI Sivakumar Syncfusion Team September 13, 2006 01:16 AM UTC

Hi Ahmed,

Sorry for the delay in getting back to you.

I here with attached a sample to overcome the issue you are encountering. with these changes you can bind the grid any where in the page i.e, ''pageLoad or on any
other control''s event''

InitializingGridWorkAroundWithTemplates.zip


Here is the description of the sample:
---------------------------------------------------------

We programatically create the Connection, OleDbDataAdapter and DataSet. Then we point the grid''s DataSource as this DataSet.

We bind the grid with no records at the first load in Init( this is essential because the grid has to get its schema at Init)

We use session variable to maintain the Lastselected Value(''SupplierId'' in this sample) used for query.

Here in the sample attached we fill the grid on a button click based on SupplierID ,

so we store this ''SupplierID'' in the Session Variable and then in Every postback we fill the grid with the same data in Init,
(by passing the sessionID) and so editing and other features will also work fine.

The select command of the adapter get its select criteria from the session variable to fill the adapter and then bind the grid with its dataset.

I included a unbound column for holding the checkboxes, this checkbox will store the value
in viewstate accross postbacks !!!.


Hope the sample is pretty simple to understand, so by seeing the sample it should help you to implement in your project (Please let me know if I have to modify anything more)


Note:
--------
We used ''OleDbDataAdapter'' to fill the ''Dataset'' which is the datasource of the grid.
We have used the ''Nwind'' database which points to our syncfusion virtual directory so if you have syncfusion installed in your machine ,
by modifying the webinfo file and making the sample as application, making some necessary register tag prefix chanes in aspx file
the sample should run on your machine

Let me know if you have any queries.

Best Regards,
A.Sivakumar


AD Administrator Syncfusion Team September 17, 2006 12:34 PM UTC

I tried the sample and it''s still not working
I have The checkboxes in template columns work good and keep its view state if u bind in the (init)but if I bind in anyother event it act in a strange way (it doesn''t keep its state or it doesn''t call it''s event handler)

please replay as soon as possible
Regards


AD Administrator Syncfusion Team September 17, 2006 01:51 PM UTC

sample not work good with checkbox

The code:
=========
- at init I fill a dataset with a 10 rows of certain table and bind the grid to this dataset
''wsProvider.FillDataSet("SELECT * FROM security ", dsDataset1, "security", 0, 10)

- then at the page load (or any other event) I bind the data grid with 5 rows of the same table

===============================
The check boxes doesn''t keep it''s state although every time I bind the datagrid in the init event

synchfusiontest.zip


AD Administrator Syncfusion Team September 17, 2006 11:23 PM UTC


I am not sure why does the sample posted above is not working for you.

please refer to this forum where we illustrate a
sample using checkbox in a unbound column.

http://www.syncfusion.com/support/forums/message.aspx?MessageID=48204

Best Regards,
A.Sivakumar


AD Administrator Syncfusion Team September 18, 2006 06:54 AM UTC

it doesn''t work because I used ur work around to be able to bind the grid in events other than (page_init) but ur work around didn''t work


AD Administrator Syncfusion Team September 18, 2006 06:55 AM UTC

it doesn''t work because I used ur work around to be able to bind the grid in events other than (page_init) but ur work around didn''t work

AND SO I''m NOT ABLE TO BIND THE GRID IN ANY OTHER EVENTS


SI Sivakumar Syncfusion Team September 18, 2006 11:58 AM UTC

Hi Ahmed,

I could see this issue in .Net 2.0, The confusion caused becasue we tried here in .Net 1.1 Framework. We will do some investigation
on this in 2.0 framework and will get back to you.

Thanks,
A.Sivakumar


SI Sivakumar Syncfusion Team September 18, 2006 05:46 PM UTC

Hi Ahmed,

It seems to confuse both a while, Also When I get the viewstate not maintaining in your vb sample, the problem was the
''SessionState'' is not handled properly.

Let me explain in brief.

We use session variable to maintain the LastSelected Value(''''SupplierId'''' in this sample) used for query. i.e we will
bind the grid in Page''s INIT for any postback occured, then based on the reason of postback you
can bind the grid inside any event here you can compare the values and can decide. Now the session state value
gets changed which will be used again in INIT event, for any operations in subsequent postbacks.

I modified your "VB" sample and attached here, this sample is much similar to the one I snd before.
Also if you are still not able to acheive the behavior , can you please modify the sample
I send now with your needs, so that it will help us a lot to know about the issue.


Please let us know if you connot use this workaround in your scenario for any reason. Also let us know if you need more help


testsynchfusion_Modified.zip


Thanks,
A.Sivakumar


AD Administrator Syncfusion Team September 20, 2006 08:51 PM UTC

it''s still confusing
should I bind the datagrid in the page init with the same data or the same datagrid or what

please just tell me the role

>Hi Ahmed,

It seems to confuse both a while, Also When I get the viewstate not maintaining in your vb sample, the problem was the
''SessionState'' is not handled properly.

Let me explain in brief.

We use session variable to maintain the LastSelected Value(''''SupplierId'''' in this sample) used for query. i.e we will
bind the grid in Page''s INIT for any postback occured, then based on the reason of postback you
can bind the grid inside any event here you can compare the values and can decide. Now the session state value
gets changed which will be used again in INIT event, for any operations in subsequent postbacks.

I modified your "VB" sample and attached here, this sample is much similar to the one I snd before.
Also if you are still not able to acheive the behavior , can you please modify the sample
I send now with your needs, so that it will help us a lot to know about the issue.


Please let us know if you connot use this workaround in your scenario for any reason. Also let us know if you need more help


testsynchfusion_Modified.zip


Thanks,
A.Sivakumar


SI Sivakumar Syncfusion Team September 21, 2006 03:05 AM UTC

Hi Ahmed,

Sorry, If I am not clear. Hope the sample I sent to you runs sucessfully there.

Let me explain the solution more clear by a example.

Consider the following:
-----------------------

a) The DataTable''s name used to bind the grid is ''Table1'' contains some fields like ID,
someVal...

b) You want to bind the grid in a Page''s Load event, based upon some ViewState value
for some reason with the ''Table1''.

c) Also You want to show the grid based on the ''someVal'' field of Table1.
(//pseduocode Eg: sqlSelectCommand=Select * from Table1 where someVal=''6'')
where the ''somVal'' field will be based on some ViewState value in the sample.

Note: ''6'' is a example here for the first time the page loads.


To do the above follow the below steps:
----------------------------------------

1) Grid should be bind to the Page_Load event to ''Table1'' based on some ViewState Value.
(say ''someVal''=''6'' where someVal is a field in Table1 as mentioned before)

2) Store the ''someVal'' in some ''Session'' variable (Session["obj"]=6)

3) Then again the grid can be binded in Page_Init in the next/subsequent postbacks, based on the Session["obj"] value.
(say some button click / any of grid''s default behavior triggered this postback)

(Also **We need to bind the grid using the same SqlQuery we used in last postback, whatever if it is made in
page_Load/Page_Init doesn''t matter) see point 4 for more understanding

**4) In the Page''s Load Event, We WILL ONLY BIND THE GRID IF THE Session["obj"] value DIFFERS FROM THE NEWVALUE( i.e if someval''s related
ViewState value gets changed) till that it will be binded in Init only. (say now you want to bind the grid, where someVal=''8'').

5) Now, the Session["obj"] is stored as ''8'' and till the user needs a change of this for some reason/based on any valuechange,
the grid will be binded in Page''s Init Event where someVal=''8''. (i.e step3 alone will be executed.)



The solution we have provided is obtained in a bit tricky way, hope that was causing the confusion.


Please feel free to let us know if you still need more info, also provide feedbacks if any.

Also let us know if this will not work in your scenario for some reason.

Best Regards,
A.Sivakumar


AD Administrator Syncfusion Team September 21, 2006 10:30 AM UTC

here is what I''m doing
''''''''''''''''''''''''''''''''''''''''''''''''
in the page_init I bind the data grid to session variable that contain a dataset
(cause I build the sqlquery dynamically in the page )

dg.datasource= session("ds")
dg.datamember=session("ds").tables("Table0")
dg.databind


-- in the btnclick event The dataset cahnges so I change the session varible and bind again

session("ds")= Ds ''New value of the dataset
dg.datasource= session("ds")
dg.datamember=session("ds").tables("Table0")
dg.databind

--------
This works ok with the check box but another problem rise with grid width and frozen columns

I found that the grid is cut at the width that I''ve set and no scroller bars appears and the rest of columns are not visible






AD Administrator Syncfusion Team September 22, 2006 07:10 AM UTC

Hi Ahmed,

We will get back to you as soon as possible, sorry for the inconvenience caused.

Thanks
A.Sivakumar


AD Administrator Syncfusion Team September 25, 2006 08:56 AM UTC

Hi Ahmed,

Hope the issue above with frozen rows/columns is similar to the issue you mentioned in the following forum

http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=48929&TabID=2

So as mentioned in the above forum upgrading to 4.3 version will solve this.

Thanks,
A.Sivakumar

Loader.
Live Chat Icon For mobile
Up arrow icon