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

Only one operation add or update in gridview.

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manoj
Top achievements
Rank 1
Manoj asked on 27 Sep 2010, 10:26 AM
Hi friends!!!!!!!
I am using RagGridView, i want that user should allowed to do single operation at a time, whether he allowed to add the record or he can only edit the record, he will not allowed to do both the operation at once.


How can i achieve this please help?

Thanks in advance.

Manoj Gupta

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 Sep 2010, 11:08 AM
Hello Manoj,

You can either cancel the insert/edit operation when performing other. Or you can close the insert form when clicking Edit Button and vice versa.The following code snippet shows how to cancel one operation when performing other.

C#:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
    {
       if (e.CommandName == RadGrid.EditCommandName)
        {
            if (RadGrid1.MasterTableView.IsItemInserted)
            {
                e.Canceled = true;
            }
        }
       if (e.CommandName == RadGrid.InitInsertCommandName)
       {
           if (RadGrid1.EditItems.Count > 0)
           {
               e.Canceled = true;
           }
       }
     }

The following is the code will help you to close the insert form when clicking Edit Button and vice versa.

C#:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
 {
    if (e.CommandName == RadGrid.EditCommandName)
    {
        RadGrid1.MasterTableView.IsItemInserted = false;
    }
    if (e.CommandName == RadGrid.InitInsertCommandName)
    {
        RadGrid1.MasterTableView.ClearEditItems();
    }
 }

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