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

Normal DataGrid Equivalent Property

3 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sandeep
Top achievements
Rank 1
Sandeep asked on 11 Jul 2008, 03:34 PM


Hi all,

I am implementing the edit mode in a RadGrid.

The code for a normal ASP.NET datagrid is simple and it boils down to

protected void MyDataGrid_Edit(object sender, DataGridCommandEventArgs e)
{
   MyDataGrid.EditItemIndex = e.Item.ItemIndex;
  BindGrid()

}


BUT i am not finding the exact equivalent for "MyDataGrid.EditItemIndex = e.Item.ItemIndex"   in a RADGRID.

it throws a compilation error if i write

radGrid.EditItemIndex = e.Item.ItemIndex


So can anyone send me the equivalent for the below line for a RadGrid ?
MyDataGrid.EditItemIndex = e.Item.ItemIndex


Any alternative solutions welcome

Thanks,
Sandeep

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Jul 2008, 06:21 AM
Hi Sandeep,

In RadGrid you can use GridEditCommandColumn which will put the item in edit mode when the Edit button is Clicked(you dont have to write code for that).

ASPX:
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn" Visible="true" ></telerik:GridEditCommandColumn> 
 

Or else if you are using a GridButtonColumn to put the Grid in Edit mode you can try the following code snippet in the Edit command event.

ASPX:
 <telerik:GridButtonColumn CommandName="Edit" HeaderText="EditCol" ButtonType="LinkButton" Text="EditItem" ></telerik:GridButtonColumn> 
                

CS:
 protected void RadGrid1_EditCommand(object source, GridCommandEventArgs e) 
    { 
        e.Item.Edit = true
        RadGrid1.Rebind(); 
    } 


Thanks
Shinu.
0
Morris Coffey
Top achievements
Rank 1
answered on 30 Jul 2008, 11:09 PM
Thanks for the info.

I have been stuck trying to escape from the edit mode.  On asp.net grids, I was using DataGrid.EditItemIndex = -1 to complete an updateCommand event.  I replaced code with e.Item.Edit = False and now works.
0
Shinu
Top achievements
Rank 2
answered on 31 Jul 2008, 04:21 AM
Hi Morris,

You can also try the following line of code to clear all the edit items in RadGrid.

CS:
RadGrid1.MasterTableView.ClearEditItems(); 



Thanks
Shinu.
Tags
Grid
Asked by
Sandeep
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Morris Coffey
Top achievements
Rank 1
Share this question
or