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

Default edit mode for specific checkbox column for all rows

1 Answer 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
eric
Top achievements
Rank 1
eric asked on 01 Feb 2009, 08:29 AM
Hi All, I have simple grid control which I like to have in edit mode when the grid is created. But only for one column as a checkbox which is boolean value in the database.  Then when a user clicks the checkbox, I would like boolean value to be updated via AJAX and show some progress that something is happening. I'm new to this. Pls guide me. 

Many Thanks,

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Feb 2009, 04:49 AM
Hi Eric,

Try the following code snippet to set the entire Grid in edit mode on load itself.

CS:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
        { 
            item.Edit = true
        } 
        RadGrid1.MasterTableView.Rebind(); 
     } 

You can set the ReadOnly property for all the other columns (which you dont want to set in edit mode) other than the GridCheckBox column to true. You can perform the update operation on clicking the CheckBox  in its CheckChanged event.

CS:
  protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            CheckBox chkbx = (CheckBox)item["CheckCol"].Controls[0]; 
            chkbx.AutoPostBack = true
            chkbx.CheckedChanged += new EventHandler(chkbx_CheckedChanged); 
 
        } 
         
    } 
    void chkbx_CheckedChanged(object sender, EventArgs e) 
    { 
        CheckBox chkbx = (CheckBox)sender; 
       //perform Update operation here 
    } 


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