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

[Solved] checkbox within radgrid

2 Answers 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sneha Gokarn
Top achievements
Rank 1
Sneha Gokarn asked on 14 Dec 2009, 06:11 AM
I have a grid with a templated column and a checkbox within it
I have bound a database column to it, so it shows up in the checkbox ie. when the value is 1 the checkbox is checked

now on the oncheckchanged event I want to change that value to which the checkbox refers what code can I write in the oncheckchanged event?
Thanks,

Sneha

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Dec 2009, 07:07 AM
Hello Sneha,

You can access the checkbox as shown in the code below and then update the database with the checkbox and datakeyvalues for the corresponding row.

CS:
 
    protected void CheckBox2_CheckedChanged(object sender, EventArgs e) 
    { 
        CheckBox chk = (CheckBox)sender; 
        bool status = chk.Checked; 
        string value=""
        if (chk.Checked) 
        { 
            value = "1"
        } 
        else 
        { 
            value = "0"
        } 
        GridDataItem item = (GridDataItem)chk.NamingContainer; 
        string keyvalue = item.GetDataKeyValue("CustomerID").ToString() ; 
        // prepare the query based on keyvalue and checkbox value, then update the database 
    } 

-Shinu.
0
Sneha Gokarn
Top achievements
Rank 1
answered on 14 Dec 2009, 08:22 AM
Thanks Shinu this worked great
Tags
Grid
Asked by
Sneha Gokarn
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sneha Gokarn
Top achievements
Rank 1
Share this question
or