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

Update Grid on EditCommandColumn

3 Answers 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Abdul
Top achievements
Rank 2
Abdul asked on 08 Mar 2011, 09:04 AM
Dear All, 

I am using Needdatasource for binding data to Radgrid and with DataTable.
 
I need to restrict the access to edit only one column of a row instead of all columns of that row.
I need to know a simple way to get the updated values of selected row.
I need to update other columns of the grid on the base of updated column on EditCommandEvent occured. 

Please Help.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Mar 2011, 10:16 AM
Hello Abdul,

If you want to access certain columns when grid is in edit mode, you can set other columns/controls as ReadOnly. Sample code is given below.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
       {
           GridEditFormItem item = (GridEditFormItem)e.Item;
           TextBox txt = (TextBox)item["ColumnName"].Controls[0];
           txt.ReadOnly = true;
        }
   }

And for your second and third requirement, please go throuhg the following documentation.
Updating values in-place and with edit forms
Retrieving original values for edited item
Insert/Update/Delete at database level with queries

-Shinu.
0
Abdul
Top achievements
Rank 2
answered on 08 Mar 2011, 03:12 PM
Actually not working I want the only one column to be displayed in edit form when I click on edit button. It makes the text field read only but they are still shown.
0
Abdul
Top achievements
Rank 2
answered on 08 Mar 2011, 03:39 PM
However this has worked for me.... 

protected void grd_report_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{           
    if (obj_dt.Rows.Count!=0)
    {
        grd_report.DataSource = obj_dt;
        grd_report.MasterTableView.GetColumn("Column Name").EditFormHeaderTextFormat = "";
    }
}
 
protected void ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
    {
        GridEditFormItem item = (GridEditFormItem)e.Item;
        item["Column Name"].Visible = false;
    }
}

Also Called OnDataItemBound = "DataItemBound" in aspx page
Tags
Grid
Asked by
Abdul
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Abdul
Top achievements
Rank 2
Share this question
or