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

Editing rad grid

6 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
KUHELI
Top achievements
Rank 1
KUHELI asked on 14 Mar 2012, 02:24 PM
Hi,

I am using  this grid  and want to allow user to edit few columns only say unitprice and instock. Is it possible? If yes then please help.

Thanks

6 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 14 Mar 2012, 03:03 PM
Hello,

Try setting ReadOnly property of the required Column as true.
ASPX:
<telerik:GridBoundColumn UniqueName="EmployeeID" HeaderText="EmployeeID" DataField="EmployeeID" ReadOnly="true"  ></telerik:GridBoundColumn>

Thanks,
Princy
0
KUHELI
Top achievements
Rank 1
answered on 20 Mar 2012, 08:58 AM
Thanks Princy. it worked for me. But now I am facing another problem. I am using inline editing. Earlier it was working fine but I made couple of columns read only and now If I am updating the same I am getting an exception "Microsoft JScript run time error: sys.webforms.pagerequestmanager.servererrorexception: specified argument was out of the range of valid values." Please suggest.

Thanks
0
Princy
Top achievements
Rank 2
answered on 20 Mar 2012, 11:48 AM
Hello Kuheli,

Glad to know that it worked for you.
The "Microsoft JScript run time error:" cited on your post could be due to several reasons. In order to help you better, please post the the code that you are working on.

Regards,
Princy.
0
KUHELI
Top achievements
Rank 1
answered on 21 Mar 2012, 08:19 AM
I tried again and it worked.

Thanks for your help.
0
KUHELI
Top achievements
Rank 1
answered on 21 Mar 2012, 01:04 PM
Hi, After implementing read only property to couple of columns if I am using IsItemInserted to add a new row. Columns are read only. Can we make all the columns editable?

Thanks
0
Princy
Top achievements
Rank 2
answered on 21 Mar 2012, 01:52 PM
Hello Kuheli,

In order to make the column editable in insert mode you can try the following approach in ItemDataBound event instead of setting ReadOnly property in aspx.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item.OwnerTableView.IsItemInserted && e.Item is GridEditFormInsertItem) //item is about to be inserted 
  {
     GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
     TextBox txtid = (TextBox)insertItem["UniqueName"].Controls[0];
     txtid.ReadOnly = false;
  }
  if (!(e.Item is GridEditFormInsertItem) && e.Item.IsInEditMode)   //item is about to be edit
  {
    GridEditFormItem editItem = (GridEditFormItem)e.Item;
    TextBox txtid = (TextBox)editItem["UniqueName"].Controls[0];
    txtid.ReadOnly = true;
  }
}

Thanks,
Princy.
Tags
Grid
Asked by
KUHELI
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
KUHELI
Top achievements
Rank 1
Share this question
or