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

Keep grid in edit mode

1 Answer 9 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Borislava
Top achievements
Rank 1
Borislava asked on 26 Dec 2013, 06:32 PM
I have a user control .asx with radgrid inside updatePanel . I am trying to display error(s) during insert Command and keep grid in edit mode. But its not working... code below...

 

 

 

 

<asp:UpdatePanel...
<telerik:RadGrid ID="rgGroups" 
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
</telerik:RadWindowManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="btnUpdate">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
rgGroups.MasterTableView.IsItemInserted = False
             RadAjaxManager1.ResponseScripts.Add("radalert('<b>Group Already Exists!</b>', 200, 150);")

 

 

 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 27 Dec 2013, 07:43 AM
Hi Borislava,

I'm not sure about your requirement, i guess during edit mode if insert is selected you want to display a alert. Below is a sample code snippet that i tried, please try if this doesn't help, elaborate on your requirement.

C#:
public string proceed = "yes";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (RadGrid1.MasterTableView.IsItemInserted == true)
        {
 
            proceed = "NotInsert";
        }
        else if (RadGrid1.EditItems.Count > 0)
        {
 
            proceed = "NotEdit";
        }
    }
 
 protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.EditCommandName)
        {
            if (proceed == "NotInsert")
            {
                e.Canceled = true;
                Response.Write("<script>alert('Please insert or cancel the insert operation first');</script>");
            }
        }
        else if (e.CommandName == RadGrid.InitInsertCommandName)
        {
            if (proceed == "NotEdit")
            {
                e.Canceled = true;
                Response.Write("<script>alert('Please update or cancel the edit operation');</script>");
            }
        }
    }

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