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

Access GridBoundColumn from itemtemplate column

2 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JSON
Top achievements
Rank 1
JSON asked on 18 Nov 2013, 02:13 PM
Hello,

I have a RadGrid that contains two cell's, one a gridboundcolumn and the other is an itemtemplate ( Check Box ). When the checkbox is unChecked (CheckBoxChanged) I need to clear the contents of the GridBounfColumn, but am not having much luck. 

How can I update the GridBoundColumn cell's value on the OnCheckChanged event?

Thanks,

SteveO

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 Nov 2013, 04:26 AM
Hi ,

When you want to access a Control in ItemTemplate, we access through the GridDataItem and not GridEditableItem. Please try the following code snippet to change the value of a BoundColumn on the CheckBox check.

ASPX:
<telerik:GridTemplateColumn>
   <ItemTemplate>
      <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" OnCheckedChanged="CheckBox1_CheckedChanged" />
  </ItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
    CheckBox check = (CheckBox)sender;
    GridDataItem data = (GridDataItem)check.NamingContainer;
    if (check.Checked)
    {
        data["PickUpDate"].Text = DateTime.Today.ToShortDateString();
    }
    else
    {
        data["PickUpDate"].Text = string.Empty;
    }
}

Thanks,
Princy
0
JSON
Top achievements
Rank 1
answered on 19 Nov 2013, 03:39 PM
Princy,

Thank you for your quick and accurate response!

Steve
Tags
Grid
Asked by
JSON
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
JSON
Top achievements
Rank 1
Share this question
or