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.
Unfortunately, activation email could not send to your email. Please try again.

CheckBox Column in GridGroupingControl

Thread ID:

Created:

Updated:

Platform:

Replies:

119353 Jun 10,2015 03:31 AM Jun 11,2015 08:51 AM ASP.NET Web Forms (Classic) 1
loading
Tags: GridGroupingControl
Juergen Schmitz
Asked On June 10, 2015 03:31 AM


Hi!

I'm using the GridGroupingControl with several columns. One column is a boolean column and I want to use a Checkbox to set the boolean values.

How do I achieve this? Do I need to change the ItemTemplate and EditTemplate? How do I set and get the values from my datasource to/from the template?

See screenshot column 3.

Thanks
Jürgen


Attachment: table_bool_12f10b9c.zip

Kavitha Narayanan [Syncfusion]
Replied On June 11, 2015 08:51 AM

Hi Juergen,

Thanks for using syncfusion product.

Query 1: How do I achieve this? Do I need to change the ItemTemplate and EditTemplate?

We have achieved your requirement with the help of itemTemplate. We have set checkbox control to the ‘Discontinued’ column.

Please refer the below code snippets:

[ASPX]

<ItemTemplate>

<asp:CheckBox ID="cbRowBtnTemplate" Checked='<%#Eval("Discontinued")%>' runat="server" OnCheckedChanged="cbRowBtnTemplate_CheckedChanged" AutoPostBack="true"/>

</ItemTemplate>

Query 2: How do I set and get the values from my datasource to/from the template?

We can set and get the Boolean values to datasource with the help of  SQL update query, in which Boolean values will be updated in datasource.

Please refer the below code snippets:

[CS]

GridRow gridrow = (GridRow)checkbox.Parent.Parent.Parent;

        if (gridrow.DisplayElement.Kind != Syncfusion.Grouping.DisplayElementKind.ColumnHeader)

        {

          

            var discontinued = gridrow.Record.GetValue("Discontinued");

            var productID = gridrow.Record.GetValue("ProductID");

            if (checkbox != null)

            {

                if (checkbox.Checked == true)

                {

                    discontinued = true;

                 

                }

                else

                {

                    discontinued = false;

                }

                sqlconnection.Open();

// query to update checkbox value to Discontinued column

                sqlcommand = new SqlCommand("UPDATE Products SET Discontinued = '" + discontinued + "' WHERE ProductID = '" + productID + "'", sqlconnection);

                sqlcommand.ExecuteScalar();

                sqlconnection.Close();

            }

        }

    

For your reference, we have attached the sample.

Sample:sample.zip

Please let us know if you need any further assistance.

Thanks,
Kavitha Narayanan


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.

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.

;