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

Issue Clicking Item Outside ContentTemplate of RadGrid when in EditMode

6 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon-Jon
Top achievements
Rank 2
Jon-Jon asked on 09 Sep 2011, 04:31 PM
How would I grab the radgrid close editmode if I click an item outside the masterpage? For some reason when radgrid is in editmode and click on an item outside the contenttemplate of the masterpage it causes issues.  If I could grab the radgrid and use  e.Item.Edit = false

thanks.

6 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 10 Sep 2011, 05:27 PM
Hello,

Please check code snippet.

Site1.master
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="TelerikTest.Web.Site1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click"
            Text="MasterButton" />
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
         
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

Site1.master.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace TelerikTest.Web
{
    public partial class Site1 : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void Button1_Click(object sender, EventArgs e)
        {
            Session["IsRemoveEdit"] = "true";
        }
    }
}

SiteContent1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SiteContent1.aspx.cs" Inherits="TelerikTest.Web.SiteContent1"
    MasterPageFile="~/Site1.Master" %>
 
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="head">
</asp:Content>
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="ContentButton" />
    <br />
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource" AllowMultiRowEdit="true">
        <MasterTableView>
            <Columns>
                <telerik:GridEditCommandColumn>
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="ID" HeaderText="ID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Name" HeaderText="Name">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
</asp:Content>


SiteContent1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace TelerikTest.Web
{
    public partial class SiteContent1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
 
        }
        protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            dynamic data = new[] {
                new { ID = 1, Name ="Name1"},
                new { ID = 2, Name = "Name2"},
                new { ID = 3, Name = "Name3"},
                new { ID = 4, Name = "Name4"},
                new { ID = 5, Name = "Name5"}
            };
 
            RadGrid1.DataSource = data;
        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if(Session["IsRemoveEdit"] != null)
            {
                RadGrid1.MasterTableView.ClearEditItems();
                RadGrid1.MasterTableView.Rebind();
                Session["IsRemoveEdit"] = null;
            }
        }
         
    }
}

Let me know if any concern.

Thanks,
Jayesh Goyani
0
Jon-Jon
Top achievements
Rank 2
answered on 12 Sep 2011, 07:31 PM
Thank you for the reply....i see how this might work if the button you click is on the same page as the radgrid but the button is located in a user control takes me to another page with a reportviewer on it without that radgrid...so i can't get the control to close the editmode.

is there something i can fire as the last event on that page before it leaves the radgrid page?
0
Jayesh Goyani
Top achievements
Rank 2
answered on 12 Sep 2011, 08:15 PM
Hello,

please check below link for trigger page event/method from user control.

 http://www.venkateswarlu.co.in/Articles/DotNet/Invoking_a_Page_Method_from_UserControl.aspx

Thanks,
Jayesh Goyani
0
Jon-Jon
Top achievements
Rank 2
answered on 12 Sep 2011, 08:24 PM
or how about if you click anything outside the radgrid during editmode it'll automatically cancel the edit......just trying to think different ways
0
Jon-Jon
Top achievements
Rank 2
answered on 12 Sep 2011, 08:49 PM
or maybe gray everything outside the radgrid during editmode?
0
Jon-Jon
Top achievements
Rank 2
answered on 12 Sep 2011, 11:11 PM
i think i figured it out. basically we use a session("division") for our report parameters for divisions....well seems as those that is a session in the edit of a radgrid that was changing our default setting "%" to ""
Tags
Grid
Asked by
Jon-Jon
Top achievements
Rank 2
Answers by
Jayesh Goyani
Top achievements
Rank 2
Jon-Jon
Top achievements
Rank 2
Share this question
or