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

Change GridView to EditMode when creating new row

1 Answer 51 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 25 Mar 2016, 03:42 PM

I have a gridview with 10 columns, only one is editable when not a new row. When I create a NewRow, I want that row to be editable. We've tried many different ways, but we can't get it to work. Any help would be welcome.

 

Thanks,

Jeff

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 28 Mar 2016, 07:50 AM
Hi Jeff,

Thank you for writing.

You can use the CellBeginEdit method to cancel the edit operation for particular cells/columns. The following snippet shows how you can disable the data rows editing (the new row would be editable) for two columns: 
private void RadGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{
    if (e.Row is GridViewDataRowInfo)
    {
        if (e.Column.Name == "Name" || e.Column.Name == "Date")
        {
            e.Cancel = true;
        }
    }
}

Let me know if you have additional questions.

Regards,
Dimitar
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Jeff
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or