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

Find Control(checkbox) inside RowBtnTemplate in GridGrouping Control in Codebehind

Hi,
 
How can i find Control (Checkbox) inside RowBtnTemplate in GridGroupingControl in Code behind, it can be in RowDataBound or in any private method...
 
Regards,
Venkat.

3 Replies

GS Gowri S Syncfusion Team September 27, 2012 06:45 AM UTC

Hi Venkat,

 

Thanks for using Syncfusion Products.

 

We can achieve your requirements by using the following lines in CheckedChanged event as :

 

CheckBox checkbox = (CheckBox)sender;

 

and in RowDataBound event we can achieve using RowDataBoundEventArgs  as :

 

GridRow gr = e.Row;

          

CheckBox chk = (CheckBox)gr.Cells[0].Controls[0].FindControl("cbRowBtnTemplate");

 

Please let us know if you have any concerns.

 

Regards,

 

Gowri S.



OW Owen Waldrep January 2, 2013 10:06 PM UTC

How do I iterate through the grid and find controls from code behind.  I need to access the control in each row, not just the control that fired the event and I am not doing it from RowDataBound.


BM Bala Murugan A.S Syncfusion Team January 4, 2013 09:18 AM UTC

Hi Owen Waldrep

Thanks for using Syncfusion products.

Your requirement of finding and accessing control(checkbox) inside RowBtnTemplate in each grid rows can be achieved by iterating through the rows of the Grid. Please refer to the code snippet below to achieve this.

[CodeBehind]

   protected void Button1_Click(object sender, EventArgs e)

        {

            foreach (TableRow row in this.ggc1.TopLevelTable.Rows) //Loop through each row of a grid

            {

                GridRow gvr = row as GridRow;

                if (gvr != null)

                {

                    foreach (GridCell gridCell in gvr.Cells)

                    {

                        if (gridCell is GridCellTemplated) // If grid cell is templated

                        {

                            CheckBox check = (CheckBox)gridCell.FindControl("cbRowBtnTemplate"); //find checkbox control inside templated grid cells

                            if (check != null)

                            {

                                if (check.Checked == true)

                                {

                                    //process here

                                }

                            }

                        }

                    }

                }

            }

        }

 

Please refer to the below link to download the sample application.

WebApplicationTest.zip

Please let me know if you have any concern.

Regards,

Bala Murugan A.S


Loader.
Live Chat Icon For mobile
Up arrow icon