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

Hierarchy radgrid with checkbox

3 Answers 139 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sahil
Top achievements
Rank 1
sahil asked on 12 Feb 2009, 08:07 PM
i have a requirement:

i want  a "Hierarchy  Radgrid with checkboxes" .
 now when i click on particular checkbox on radgrid in mastertable or detailview table ,
 its status is updated in database(true/false).

all thing working on click of checkbox.

Thanks in advance  for help/

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Feb 2009, 07:32 AM
Hi Sahil,

One suggestion will be to use a GridTemplateColumn witha CheckBox in its ItemTemplate. You can update the database with the current status of the CheckBox in the CheckChanged event.

ASPX:
 <telerik:GridTemplateColumn UniqueName="TempCol" DataField="Discontinued" HeaderText="Discontinued" > 
                       <ItemTemplate> 
                           <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%#Eval("Discontinued") %>' AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged" /> 
                       </ItemTemplate>  
                     </telerik:GridTemplateColumn> 

CS:
   protected void CheckBox1_CheckedChanged(object sender, EventArgs e) 
    { 
        CheckBox chkbx = (CheckBox)sender; 
        GridDataItem item = (GridDataItem)chkbx.NamingContainer; 
        bool chkSatus= chkbx.Checked; 
       // perform Update operation 
    } 


Thanks
Shinu



0
sahil
Top achievements
Rank 1
answered on 15 Feb 2009, 05:13 PM
hi

can u please explain it more
..

when i click on a particular checkbox of a radgrid , then checkchanged event is fire,

and we get that particular checkbox,

but when i use the update query , i want "category id column value" ..

update tbcategorty set checkbox=@checkbox where categoryid=@categoryid

from where i find the "category id" of a particular checkbox.??

is i have to fire item command event for that??? 
0
Accepted
Shinu
Top achievements
Rank 2
answered on 16 Feb 2009, 04:31 AM
Hi Sahil,

You can access the CategoryID column value using the Column's UniqueName property in the CheckChanged event of the CheckBox.

CS:
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)  
    {  
        CheckBox chkbx = (CheckBox)sender;  
        GridDataItem item = (GridDataItem)chkbx.NamingContainer;  
        bool chkSatus= chkbx.Checked;  
        // access the cell value using column's UniqueName property 
        string strCategoryid = item["columnUniqueName"].Text; 
       // perform Update operation  
    }  


Thanks
Shinu




Tags
Grid
Asked by
sahil
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
sahil
Top achievements
Rank 1
Share this question
or