我使用popup editform模板实现了带有添加/更新选项的telerik网格。没有ajax的每件事都很好,当我启用ajax弹出窗体时,事件没有正常触发。我已经定义了CommandName,在服务器端我实现了ItemCommand事件。如果我在窗体的所有事件上应用断点,则在单击弹出按钮后,仅调用窗体的加载方法,并且不会发生任何其他情况。请帮助以下是我的客户端代码
<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> |
<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>
<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>
<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> <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" />
<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>
答案 0 :(得分:1)
我已将您的代码复制到配置了AutoEventWireup="true"
的新网络表单中,并且当我单击“编辑”按钮时,我看到所有3个事件触发:ItemDataBound,NeedDataSource和ItemCommand。
如果您不想使用AutoEventWireup,则需要在CreateChildControls中或在页面生命周期的早期将事件处理程序中的Grid事件连接到它们的事件处理程序。
答案 1 :(得分:0)
经过多天的努力解决问题后,我发现了问题的原因。我使用System.Compression来压缩和解压缩视图状态。我认为Telerik有一些问题,这就是它停止工作的原因。在我的BasePage中评论此代码时,它开始正常工作