oncheckchanged event inside rad grid

2 posts, 1 answers
  1. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 08 Dec 2011 Link to this post

    I have a grid template column as such

    <telerik:GridTemplateColumn HeaderText="Don't Export" HeaderStyle-Width="40px" DataField="exportCheck"
                    SortExpression="exportCheck" UniqueName="exportCheck">
                        <ItemStyle Width="40px" />
                            <asp:CheckBox ID="printCheck" runat="server" AutoPostBack="false" OnCheckedChanged="printCheckChanged" />

    I am then editing the checkboxes in the code behind to dynamically set them to checked or not

    Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
            If TypeOf e.Item Is GridDataItem Then
                'get the row item
                Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
                'check to see if we need to check the box
                Dim export = DirectCast(item("export").Text, String)
                'get the checkbox
                Dim check As CheckBox = DirectCast(item("exportCheck").Controls(1), CheckBox)
                'if we need to check the box then we will get it and check it
                If (export = "no") Then
                    check.Checked = True
                End If 'if export
            End If 'if e.item
        End Sub 'itemDataBound

    What I need to do is add the oncheckchanged event. Essentially, when a user either checks a box, or unchecks a box, I need to update a database and then show a tool tip telling them it was successful. I tried doing this programmatically, and adding it in the aspx but I can't get anything to work. Can you help me out?
  2. Answer
    Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 08 Dec 2011 Link to this post


    please check below code snippet.
    <telerik:GridTemplateColumn UniqueName="MyColumn">
                                <asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="CheckBox1_CheckedChanged"
                                    AutoPostBack="true" />
    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
                CheckBox CheckBox1 = sender as CheckBox;
                // you can access grid row here
                GridDataItem item = CheckBox1.NamingContainer as GridDataItem;
                // perform here DB operation
                TableCell cell = item["MyColumn"];
                cell.ToolTip = DateTime.Now + "_Updated";

    Jayesh Goyani
Back to Top