This is a migrated thread and some comments may be shown as answers.

CheckBox in TemplateColumne

3 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jostein Solstad
Top achievements
Rank 1
Jostein Solstad asked on 17 Jan 2011, 09:57 PM
Hi!

I have a checkbox inside a templatecolumn

<telerik:GridTemplateColumn>
   <HeaderTemplate>
       <input onclick="CheckAll(this);" type="checkbox">
   </HeaderTemplate>
   <ItemTemplate>
       <asp:CheckBox ID="cbApproved" runat="server" />
   </ItemTemplate>
</telerik:GridTemplateColumn>

Now, in the UpdateCommand of the Grid, I would like to access the CheckBox from the ItemTemplate. This is because when you go into Edit Mode, the column for the CheckBox is still visible and clickable. So I woul like to check if the user has changed this value.

Id this is not posible, is it possible to lock the checkbox for the ItemTemplate when in edit mode?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Jan 2011, 05:50 AM
Hello Jostein,

You can access the CheckBox as shown below.

C#
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
  {
   if (e.Item is GridEditFormItem && e.Item.IsInEditMode)//EditMode=editform
      {
          GridEditFormItem edititem = (GridEditFormItem)e.Item;
          GridDataItem dataitem = (GridDataItem)edititem.ParentItem;
          CheckBox chkBox = (CheckBox)dataitem.FindControl("CheckBox1");
      }
  }

Thanks,
Shinu.
0
Jostein Solstad
Top achievements
Rank 1
answered on 18 Jan 2011, 03:33 PM
Ok, I can use that to disable the CheckBox.

But, how can I access this CheckBox in the UpdateCommand of the grid? Is that possible?
0
Accepted
Pavlina
Telerik team
answered on 18 Jan 2011, 04:34 PM
Hi Jostein,

You can try the code snippet below:
C#:
protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
   {
       CheckBox checkbox = (CheckBox)grdElenco.Items[i].FindControl("cbApproved");
   }

Regards,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Jostein Solstad
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jostein Solstad
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or