1

我使用弹出式编辑表单模板实现了带有添加/更新选项的 Telerik 网格。没有 ajax 一切正常,当我启用 ajax 弹出表单事件时没有正确触发。我已经定义了 CommandName 并且在服务器端我实现了 ItemCommand 事件。如果我在表单的所有事件上应用断点,那么在单击弹出按钮后,只会调用表单的 Load 方法,不会发生其他任何事情。请帮助以下是我的客户端代码

<telerik:RadGrid ID="gridMain" runat="server"  EnableEmbeddedSkins="False" Skin="MpoGrayGrid"  AutoGenerateColumns="False" CellSpacing="0" GridLines="None" OnItemDataBound="gridMain_ItemDataBound" OnNeedDataSource="gridMain_NeedDataSource" OnItemCommand="gridMain_ItemCommand">
                            <MasterTableView EditMode="PopUp" CommandItemDisplay="Top" DataKeyNames="EEHireTermID">
                            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
                            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column" Created="True"></ExpandCollapseColumn>
                                <Columns>
                                    <telerik:GridTemplateColumn HeaderText="Employee">
                                        <ItemTemplate>
                                            <asp:Label runat="server" ID="lblName"></asp:Label>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn HeaderText="Type">
                                        <ItemTemplate>
                                            <asp:Label runat="server" ID="lblType"></asp:Label>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn HeaderText="ActionDate">
                                        <ItemTemplate>
                                            <asp:Label runat="server" ID="lblActionDate"></asp:Label>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn HeaderText="Entered Date">
                                        <ItemTemplate>
                                            <asp:Label runat="server" ID="lblEnteredDate"></asp:Label>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn HeaderText="Entered By">
                                        <ItemTemplate>
                                            <asp:Label runat="server" ID="lblEnteredBy"></asp:Label>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn HeaderText="Reason  For Termination">
                                        <ItemTemplate>
                                            <asp:Label runat="server" ID="lblTermReason"></asp:Label>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn HeaderText="Memo">
                                        <ItemTemplate>
                                            <asp:Label runat="server" ID="lblMemo"></asp:Label>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn HeaderText="Action">
                                        <ItemTemplate>
                                            <asp:LinkButton runat="server" ID="btnEdit" CausesValidation="False" Text="Edit" CssClass="Link2" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' CommandName="Edit"></asp:LinkButton>&nbsp;|&nbsp;
                                        <asp:LinkButton runat="server" ID="btnDelete" CausesValidation="False" Text="Delete" CssClass="Link2" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' CommandName="Delete"></asp:LinkButton>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                </Columns>
                                <EditFormSettings InsertCaption="Add Hire/Termination Dates" CaptionFormatString="Add Hire/Termination Dates" 
                                    CaptionDataField="Id" EditFormType="Template" PopUpSettings-Modal="true" PopUpSettings-Width="663">
<EditColumn InsertImageUrl="Update.gif" UpdateImageUrl="Update.gif" CancelImageUrl="Cancel.gif" FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                    <FormTemplate>
                                        <table id="tblEdit" runat="server" width="663" style="margin: 24px; border-radius: 20px;" cellpadding="6" >

                                            <tr>
                                                <td colspan="1" class="BodyText" width="31%" >Employee: </td>
                                                <td colspan="1" width="69%">
                                                    <asp:TextBox runat="server" CssClass="TextField1" ID="txtName" ReadOnly="True"></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td colspan="1" class="BodyText" width="31%">Type:</td>
                                                <td colspan="1"  width="69%">
                                                    <asp:DropDownList runat="server" ID="ddlType" CssClass="DropDown1" onchange="changeType(this)">
                                                        <asp:ListItem Value=""></asp:ListItem>
                                                        <asp:ListItem Value="H">Hire</asp:ListItem>
                                                        <asp:ListItem Value="T">Termination</asp:ListItem>
                                                        <asp:ListItem Value="E">PEO</asp:ListItem>
                                                        <asp:ListItem Value="N">PEO Termination</asp:ListItem>
                                                    </asp:DropDownList>
                                                    &nbsp;<asp:RequiredFieldValidator ID="rfvReq1" runat="server" CssClass="Heading1" ControlToValidate="ddlType" ErrorMessage="* Required"></asp:RequiredFieldValidator></td>
                                            </tr>
                                            <tr>
                                                <td colspan="1" class="BodyText" width="31%">Action/EffectiveDate:</td>
                                                <td colspan="1"  width="69%">
                                                    <telerik:RadDatePicker runat="server" ID="rdpActionDate"></telerik:RadDatePicker>
                                                    &nbsp;<asp:RequiredFieldValidator ID="rfvReq2" runat="server" CssClass="Heading1" ControlToValidate="rdpActionDate" ErrorMessage="* Required"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="1" class="BodyText" width="31%">Reason For Termination:</td>
                                                <td colspan="1"  width="69%">
                                                    <asp:DropDownList runat="server" ID="ddlTermReason" CssClass="DropDown1">
                                                    </asp:DropDownList>&nbsp;<asp:RequiredFieldValidator ID="rfvReq3" CssClass="Heading1" runat="server" ControlToValidate="ddlTermReason" ErrorMessage="* Required"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="BodyText" width="31%">Memo:</td>
                                                <td  width="69%">
                                                    <asp:TextBox runat="server" ID="txtMemo" TextMode="MultiLine" Height="86px" Width="346px"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" align="center">
                                                    <asp:Button runat="server" ID="txtSave" CommandName="Update" CssClass="Buttons" Text="Save" />&nbsp;
                                    <asp:LinkButton runat="server" ID="btnCancel" CssClass="Link_Cancel" Text="Cancel" CommandName="Cancel" CausesValidation="False"></asp:LinkButton>
                                                </td>
                                            </tr>
                                        </table>
                                    </FormTemplate>

                            <PopUpSettings Modal="True" Width="663px" >

                            </PopUpSettings>
                                </EditFormSettings>

                            <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
                                <CommandItemTemplate>
                                    <table width="100%"  cellpadding="10">
                                        <tr>
                                            <td align="left">
                                                <asp:Button runat="server" ID="btnAdd" CommandName="InitInsert"  Text="Add New Record" CssClass="Buttons" /></td>
                                            <td align="right">
                                                <asp:LinkButton runat="server" CommandName="Export" ID="lbtnExport" Text="Export"><img src="../images/excel.jpg"/> Export</asp:LinkButton></td>
                                        </tr>
                                    </table>
                                </CommandItemTemplate>
                            </MasterTableView>
                             <ClientSettings>
                                <ClientEvents OnPopUpShowing="PopUpShowing" />
                              </ClientSettings>

                                    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
                                    <FilterMenu EnableImageSprites="False" EnableEmbeddedSkins="False"></FilterMenu>
                                    <HeaderContextMenu EnableEmbeddedSkins="False"></HeaderContextMenu>
                        </telerik:RadGrid>
4

2 回答 2

1

我已将您的代码复制到一个AutoEventWireup="true"配置的新网络表单中,当我单击“编辑”按钮时,我看到所有 3 个事件都被触发:ItemDataBound、NeedDataSource 和 ItemCommand。

如果您不想使用 AutoEventWireup,则需要在 CreateChildControls 中或更早的页面生命周期中将 Grid 的事件适当地连接到它们的事件处理程序。

于 2013-04-26T15:27:34.497 回答
0

在尝试了很多天解决问题后,我找到了问题的原因。我使用 System.Compression 来压缩和解压缩视图状态。我认为 Telerik 有一些问题,这就是它停止工作的原因。在我的 BasePage 中评论此代码时,它开始正常工作

于 2013-04-30T20:52:44.717 回答