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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Check box column in GridGroupingControl (ASP.NET)

Thread ID:

Created:

Updated:

Platform:

Replies:

48204 Aug 22,2006 12:48 PM UTC Sep 4,2006 11:52 AM UTC WinForms 12
loading
Tags: GridControl
Dheeraj
Asked On August 22, 2006 12:48 PM UTC

I would like to add a check box Column in a GridGroupingControl in ASP.NET. I am not getting any sample doing that in ASP.NET though samples are available for Windows Forms. Unfortunately that code doesn''t work for ASP.NET.

I want the check box column to have normal functionality of checking and unchecking selected rows (if possible "Select All" also)

Thanks,
Dheeraj

Suresh Babu [Syncfusion]
Replied On August 22, 2006 09:45 PM UTC

Hi Dheeraj,

You can use ItemTemplate to achieve this behavior. to provide ItemTemplate for the desired column please do as follows

Steps to do:
1. Right click the GridGroupingControl and click ''Edit Template''.
2. choose the ''Column'' in which you want to place Check Box.
3. Drag and place the Check Box into the Item Template box.
4. Right click the ''Edit Template'' and choose ''End Edit Template''.

Now you will get a Check Box column in GridGroupingControl. The Check box''s Checkedchanged event gets value of the field ''CategoryID'' from GridGroupingControl and displays the field value of records which are checked. If any record is unchecked then that record value will not be listed.

Please have a look at the following KB for adding Check Box to GridGroupingControl.

http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=243

And Here is the sample which illustrates this
CheckBox Column


Note: I assume that you are using VS.NET2005. and so created the sample in the .Net2005 version.

Thanks for your interest in using our products.

Let us know if you have any more queries.

Thanks,
Suresh Babu

Dheeraj
Replied On August 23, 2006 08:03 AM UTC

Hi Suresh Babu,

I am using VS.Net 2003.

The ItemTemplate method is not the one I am looking for as it adds the check box in every column (in an unbound data grid). I need a single column with check box.

The zipped sample you have was helpful. Though I am not sure how to use it for an Unbound dataset. When I put this column in my GGC, only this column is visible and rest of the queried columns (being unbound, I get them at runtime) do not appear.

What I have is an unbound datagrid and I want to prepend a checkbox column to it. (I could do this using .Net''s controls but want to do this with Syncfusion controls)

Thanks,
Dheeraj

Suresh Babu [Syncfusion]
Replied On August 24, 2006 02:04 AM UTC

Hi Dheeraj,

I was able to reproduce this issue.

You can use ItemTemplate to achieve this behavior. To provide ItemTemplate for the desired column please follow these procedures.

Steps to do:

1. Set GridGroupingControl''s DataSource and DataMember.
2. Set GridGroupingControl''s PostBackOnRowDblClick property to False.
3. Add an Unbound Column to the GridGroupingControl.
4. Right click the GridGroupingControl and click ''Edit Template''.
5. choose the ''Column Templates...'' and then select the Unbound column in which you want to place the CheckBox.

If you did not get ''Column Templates...'' then place the following code in .aspx file

[ASPX]

$sfwg:GridColumnDescriptor Name="Check">
$ItemTemplate>
$asp:CheckBox id="RecordCheck" runat="server" Text=" ">$/asp:CheckBox>
$/ItemTemplate>
$/sfwg:GridColumnDescriptor>

6. Drag and place the Check Box into the Item Template box.
7. Right click the ''Edit Template'' and choose ''End Edit Template''.

Now you will get a Check Box column in GridGroupingControl.

Please have a look at the following KB for adding Check Box to GridGroupingControl.

http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=243

Here is the sample which illustrates your requirements,

Template CheckBox Column


Thanks for your interest in using our products.

Let us know if you have any more queries.

Thanks,
D.Suresh Babu

Dheeraj
Replied On August 24, 2006 06:37 AM UTC

Hi D.Suresh Babu,

I noticed that in your attached sample, you are using syncfusion version 4.301.0.0 where as what I have is 4.201.0.37. So I am not getting ColumnTemplate action to add the check box for a particular column.

Also it looks like syncfusion controls always Need bound columns (rather than unbound columns) Using bound columns I could get the checkbox column.

Thanks,
Dheeraj

Suresh Babu [Syncfusion]
Replied On August 25, 2006 03:14 AM UTC

Hi Dheeraj,

I apologize for the inconvenience caused.

Here is the sample which contains an Unbound CheckBox column and uses Syncfusion Essential grid version 4.2.0.37.

Unbound CheckBox Column


In this sample, we created an unboundcolumn in ''Unboundfields'' and the CheckBox is added in ''ItemTemplate'' field of the Unboundcolumn.
From your previous post it seems like you are trying to add unbound columns through code
so please let me know if you need us to illustrate template column through code.


Note: Sample uses Nwind data base pointing to Syncfusion virtual directory, So if you have any of our Versions installed this will get the data from there .
Also you have to modify the webinfo file and create this sample as a application to run on your machine.

please let us know if you need further assistance.

Thanks,
D.Suresh Babu

Dheeraj
Replied On August 25, 2006 06:07 AM UTC

Yes, as I had said in my previous mail, I could add an unbound check-box column to a bound datagrid.

Please provide a sample to add an unbound check-box column to an Unbound datagrid.

Also I want to catch events when the user checks/unchecks a row on the GGC, so I believe that SelectedRecodsChanged/Changing should be suffice to handle?

Thanks,
Dheeraj

Suresh Babu [Syncfusion]
Replied On August 26, 2006 02:15 AM UTC

Hi Dheeraj,

We are started to create sample to overcome this issue.

We will get back to you at the earliest.

Sorry for the inconvenience caused.

Thanks,
D.Suresh Babu

Sivakumar [Syncfusion]
Replied On August 30, 2006 09:10 PM UTC

Hi Dheeraj,

I apologize for the delay in getting back to you. We are facing some difficulties when we try to use the checkbox as a template in a grid through code.

So we are looking for some alternate ways to illustrate this in the sample. Hope we will come up with some solutions soon

In the mean time Just to make sure that our Grid team is going in the right direction, can you confirm whether the following reflects your scenario?

In our sample (under progress) we acheive the Unbound Grid behavior by creating a dummy DataTable(for example 4 columns and 5 rows) and
pass it to the grid and then you can fill the data in those cells by handling the QueryCellStyleInfo Event.

But by looking in to your previous updates it seems you are using some other way to make the grid as unbound grid.
Can you please update us if we are on the right track?.

Again I apologize for the delay.


Thanks,
A.Sivakumar

Dheeraj
Replied On August 31, 2006 06:33 AM UTC

Hi A. Sivakumar,

The process of getting the data is very simple. Fire a query on a database and fill a dataset using data adapter. Make the grid''s datasource to be the filled dataset and bind. The grid should show up.

There is no external filling of data here. Data comes from the database as a dataset with a query. What is needed is to add a checkbox column to this grid and allow the user to select some rows and also catch the events after selecting the data.

Thanks,
Dheeraj

Dheeraj
Replied On August 31, 2006 06:43 AM UTC

Just one more clarification that the columns that make the grid are those that are queried at runtime. No columns should be added to the grid at design time. In future if I have to add new columns to the grid, I just modify the query and no extra thing is needed.

Sivakumar [Syncfusion]
Replied On September 3, 2006 11:04 PM UTC

Hi Dheeraj,

Thanks for your description, that helped us to understand much better and was able to come up with a solution.
Previously we taught you are looking for some unbound grid acheived as I said in my previous post.

I have attached a sample which uses the steps mentioned below to acheive the beavior you mentioned.

please download the sample from the below link:

Sample illustrating checkbox in a unbound column and binding of data


Steps used in the sample:
----------------------------

a) Configuring the grid:
---------------------

We connected to the ''Nwind'' DataBase which points to the syncfusion virtual directory through code.
We fire a query on a database and fill the dataset using data adapter. and then the grid''''s datasource
is filled with the dataset and binded in Page''s Init event.


b) Adding a UnboundColumn dynamically to the grid :
------------------------------------------

You can initialize a unboundColumn and can make use of it to add in the Tabledescriptor''s column dynamically
by using the following code:

this.GridGroupingControl1.TableDescriptor.UnboundFields.Add("UnboundColumn");
this.GridGroupingControl1.TableDescriptor.Columns.Add("UnboundColumn");
this.GridGroupingControl1.TableDescriptor.VisibleColumns.Add("UnboundColumn");

c) Creating a TemplateClass implementing Itemplate Interface.
-----------------------------------------------------------

Please look in to the following kb on adding Templates through code.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=373

**d) Declare the unbound column as a templated column in Page_Init.
--------------------------------------------------------------

This is one of the important step that needs to be used for the checkbox to retain its viewstate for each postback
when we bind the grid through code by firing a query to dataset.

// you can also use any control here, this is just for defining the column as templates
// Use ''QueryCellStyleInfo'' event to add checkbox as the control.
Control ctrl=new Control();
//see the TemplateClass in code.
TemplateClass tc=new TemplateClass(ctrl);// The template class created in step c)
this.GridGroupingControl1.TableDescriptor.Columns.FindByMappingName("UnboundColumn").ItemTemplate=tc;


e) Handle ''QueryCellStyleInfo'' event to to add checkbox to each cell
-----------------------------------------------------------------

In the ''QueryCellStyleInfo'' event check for the ''UnBoundColumn'' and then apply the checkbox as a template for
each ''RecordRow''. see the sample for more info


* f) Getting the selected records when the user checks/unchecks a row on the GGC
-----------------------------------------------------------------------------

In the CheckBox''s CheckedChanged event, it is shown how to get any fields in that record for the row
in which the user clicked the checkbox.See the chkBox_CheckedChanged event in sample for moe info.

Note: In the sample we used a update button and clicking on this Update button will cause a postback
and CheckedChanged event is fired for the checkboxes whose state the user toggled.
if you want the CheckBox''s CheckedChanged event to fire for each time a checkbox state is toggled,
please make the checkbox control''s ''AUTOPOSTBACK'' property to true inside ''QUERYCELLSTYLEINFO'' event.
please look in to ''QUERYCELLSTYLEINFO'' event and also comments in sample for more info.


Once again kindly accept my apology for the delay in responding to you.

Let us know if you need more info.

Best Regards,
A.Sivakumar

Dheeraj
Replied On September 4, 2006 11:52 AM UTC

Hi A. Sivakumar,

Thanks for a working sample provided. I could see the behavior and it''s working as expected.

I shall get back to you if I require anything additional.

Thanks Once Again,
Dheeraj

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;