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

UserControl Edit - Cancel Not Firing

1 Answer 164 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Baatezu
Top achievements
Rank 2
Baatezu asked on 20 Jan 2008, 08:17 AM
I'm pretty new to Telerik, and I've researched this problem for a few days and none of the solutions I've found have worked for me.
I'm using DotNetNuke 4.8.0, VS2008 (9.0.2.21022.8 RTM). Tested in FF 2.0.0.11 and IE 7.0.6000. This is running on my local Vista Ultimate machine with IIS 7.0.6000. I am using .netTiers as my DAL.
I'm using the trial version - ASP.NET Q3 2007 SP1 (Version Number 2007.3.1314

What my problem is - When I click Update or Cancel, it doesn't close the edit form. The page does a postback, but the edit form is still open. I don't notice any Events firing that are firing as a result of the Cancel button, just those of a page reloading.
If I don't use a custom edit form, the default Cancel operates normally.

Any pointers would be great, I assume I'm missing something simple; I just can't see it.
Both the Edit Control and the Control with the Grid on it are posted in full below.

Thanks

My ascx with the Grid control is
<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="ViewTestModule.ascx.cs" Inherits="GS_Marketplace.DotNetNuke.Modules.TestModule.ViewTestModule" %> 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
<asp:Label ID="lblDebug" runat="server">Vroom?</asp:Label> 
 
<telerik:RadGrid Skin="WebBlue" ID="RadGrid1" runat="server" 
            GridLines="None" AllowPaging="True" AllowSorting="True"  
    Width="97%" AutoGenerateColumns="False" ShowStatusBar="True"  
    OnNeedDataSource="RadGrid1_NeedDataSource"  
    OnUpdateCommand="RadGrid1_UpdateCommand"  
    OnInsertCommand="RadGrid1_InsertCommand"  
    OnDeleteCommand="RadGrid1_DeleteCommand"  
    oncancelcommand="RadGrid1_CancelCommand"
 
    <MasterTableView EnableViewState="True" EnableColumnsViewState="True" CurrentResetPageIndexAction="SetPageIndexToFirst" DataKeyNames="GenderTypeID" 
            Frame="Border" TableLayout="Auto" CommandItemDisplay="Top"
        <RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" Visible="False"
            <HeaderStyle Width="20px"></HeaderStyle> 
        </RowIndicatorColumn> 
 
        <ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" Visible="False" Resizable="False"
            <HeaderStyle Width="20px"></HeaderStyle> 
        </ExpandCollapseColumn> 
        <Columns> 
            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn> 
            <telerik:GridBoundColumn UniqueName="GenderTypeID" HeaderText="ID" DataField="GenderTypeID"></telerik:GridBoundColumn> 
            <telerik:GridBoundColumn UniqueName="Description" HeaderText="Description" DataField="Description"></telerik:GridBoundColumn> 
            <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete" /> 
        </Columns> 
        <EditFormSettings UserControlName="~/DesktopModules/Goldstar Consulting.TestModule/TestAddControl.ascx" EditFormType="WebUserControl"
            <EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
        </EditFormSettings> 
    </MasterTableView> 
</telerik:RadGrid> 

My UserControl edit ascx is
<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="TestAddControl.ascx.cs" Inherits="GS_Marketplace.DotNetNuke.Modules.TestModule.TestAddControl" %> 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
<asp:Label ID="lblDebug" runat="server"></asp:Label> 
<div> 
    <telerik:RadTextBox EnableViewState="True" ID="RadTextBox1" Runat="server"  
        EmptyMessage="New Gender Type" Label="Gender" Text='<%# DataBinder.Eval(Container, "DataItem.Description") %>'  
        TextMode="SingleLine" Height="20px" Width="237px"
    </telerik:RadTextBox> 
</div> 
 
<div align="right"
    <asp:button EnableViewState="True" id="btnUpdate" text="Update" runat="server" CommandName="Update" Visible='<%# !(Container is Telerik.Web.UI.GridInsertionObject) %>'></asp:button> 
            <asp:button  EnableViewState="True" id="btnInsert" text="Insert" runat="server" CommandName="PerformInsert" Visible='<%# Container is Telerik.Web.UI.GridInsertionObject %>'></asp:button> 
            &nbsp; 
            <asp:button  EnableViewState="True" id="btnCancel" text="Cancel" runat="server" causesvalidation="False" commandname="Cancel"></asp:button> 
</div> 
The only thing I have in the code is some simple DataBinding in PageLoad
 protected void Page_Load(object sender, EventArgs e) 
        { 
            try 
            { 
                if (!IsPostBack) 
                { 
                } 
 
                GenderTypeService genderTypeService = new GenderTypeService(); 
                int totalCount = 0; 
                TList<GenderType> genderTypeList = genderTypeService.GetPaged(GenderTypeColumn.Deleted + " = 'false'", GenderTypeColumn.GenderTypeId.ToString(), 0, 10, out totalCount); 
 
 
                RadGrid1.DataSource = genderTypeList.ToDataSet(false); 
                RadGrid1.DataBind(); 
            } 
            catch (Exception ex) 
            { 
                Exceptions.ProcessModuleLoadException(this, ex); 
            } 
        } 

1 Answer, 1 is accepted

Sort by
0
Kiara
Top achievements
Rank 1
answered on 22 Jan 2008, 03:11 PM
Baatezu, I see that you have DataBind() calls and bind the grid to data only on initial load. Data editing should be supported without additional coding if you supply the data source for the grid inside the NeedDataSource event handler:

Online demo

Revise your code to see how it goes.

Kiara
Tags
Grid
Asked by
Baatezu
Top achievements
Rank 2
Answers by
Kiara
Top achievements
Rank 1
Share this question
or