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

Detect if grid is in edit mode

3 Answers 789 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 03 Jun 2014, 12:34 PM
I would like to find out in the ItemCreated event if one of the rows in the grid is in edit mode.

I am using InPlace editing and I would like to prevent the user from clicking one of the other commands in rows that are not in edit mode.
Also I need to disable some other fields in my form if the user is editing an item.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Jun 2014, 12:57 PM
Hi Erik,

I guess you want to have only one row to be edited at a time. You can set  AllowMultiRowEdit="false". If you want to cancel any other commands you can use ItemCommand event and check the commands and cancel them. Check this article which shows how to allow either Insert or Edit at a time. Elaborate on your requirement if this doesn't help.

Thanks,
Princy
0
Erik
Top achievements
Rank 1
answered on 03 Jun 2014, 02:03 PM
Hi Princy, 

I also need to disable some other controls on my form (which are not part of the grid). So I just need to know if one of the items is in edit mode.
MultiRowEdit does not disable any command buttons of other rows (I added some extra command buttons).

I can see in the ItemCommand callback that the user clicked "edit" but this event comes AFTER the ItemCreated event so this is too late for setting enabled/visibility of items in the grid.
0
Princy
Top achievements
Rank 2
answered on 04 Jun 2014, 06:03 AM
Hi Erik,

I'm not clear about your requirements. I guess you have other ButtonColumns in your grid and you want to disable it when the grid is in edit mode. Please try the following code snippet. If neccessary provide your code snippet.

ASPX:
<telerik:GridButtonColumn CommandName="Select" Text="Select" ButtonType="LinkButton" UniqueName="ButtonColumn">
</telerik:GridButtonColumn>

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
//Checks if in edit mode
    if (RadGrid1.EditItems.Count > 0)
    {
        foreach (GridDataItem dataItem in RadGrid1.Items)
        {
           //Access the button
            LinkButton lnkbtn = (LinkButton)dataItem["ButtonColumn"].Controls[0];
            lnkbtn.Enabled = false;          
        }
    }
}

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