2

我有一个更新面板和一个gridview,gridview 中的每一行都有2 个按钮。当我单击按钮时,更新进度开始运行,但按钮的事件不会触发。这在我的设计代码中:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                      <asp:Panel ID="Panel1" runat="server" ClientIDMode="Static" CssClass="radtabclass inlineDiv">
                        <telerik:RadTabStrip ID="RadTabStrip1" runat="server" Orientation="HorizontalTop" SelectedIndex="0" MultiPageID="RadMultiPage1" Skin="Vista">
                            <Tabs>
                                <telerik:RadTab Text="Docs" PageViewID="RadPageView1" />
                                ...
                            </Tabs>
                        </telerik:RadTabStrip>
                        <telerik:RadMultiPage runat="server" ID="RadMultiPage1" SelectedIndex="0">

                            <telerik:RadPageView runat="server" ID="RadPageView1">
                                <asp:GridView ID="RequestDocGridView" ShowHeaderWhenEmpty="true" ShowHeader="true" CssClass="searchresult_gridview" runat="server" AllowPaging="true" AutoGenerateColumns="False" CellPadding="4" GridLines="None" OnRowCommand="RequestDocGridView_RowCommand"
                                    AlternatingRowStyle-CssClass="AlternatingRowStyle" SelectedRowStyle-CssClass="SelectedRowStyle" EditRowStyle-CssClass="EditRowStyle" FooterStyle-CssClass="FooterStyle" RowStyle-CssClass="RowStyle" PagerStyle-CssClass="PagerStyle" HeaderStyle-CssClass="HeaderStyle" PagerSettings-Mode="NumericFirstLast">
                                    <Columns>
                                        <asp:BoundField DataField="DocumentsByCustomer.DocumentName" HeaderText=" Name" HeaderStyle-CssClass="HeaderStyle" ReadOnly="true" />
                                        <asp:CheckBoxField DataField="IsAvailable" HeaderText="Available" HeaderStyle-CssClass="HeaderStyle" ReadOnly="true" />
                                        <asp:CheckBoxField DataField="DocumentsByCustomer.IsForcible" HeaderText="Force" HeaderStyle-CssClass="HeaderStyle" ReadOnly="true" />
                                        <asp:TemplateField HeaderText="View" HeaderStyle-CssClass="HeaderStyle">
                                            <ItemTemplate>
                                                <asp:ImageButton ID="ViewDocumentImageButton" runat="server" ImageUrl="~/Images/DocumentPicture16x16.png" ToolTip="View" OnClick="ViewDocumentImageButton_Click" />
                                            </ItemTemplate>
                                        </asp:TemplateField>

                                        <asp:TemplateField >
                                            <ItemTemplate>
                                                <asp:Button ID="btnInsert" runat="server" Text="Insert" OnClick="btnInsert_Click" />
                                                <asp:Button ID="btnEdit" runat="server" Text="Edit" OnClick="btnEdit_Click" />

                                                 <asp:Button ID="InsertButton" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" CommandName="Insert" runat="server" Text="Insert" />
                                                <asp:Button ID="EditButton" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" CommandName="Edit" runat="server" Text="Edit" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </telerik:RadPageView>

                            <telerik:RadPageView runat="server" ID="RadPageView2">
                               ...
                            </telerik:RadPageView>

                        </telerik:RadMultiPage>
                    </asp:Panel>

                    <asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="1" DynamicLayout="true" AssociatedUpdatePanelID="UpdatePanel1" ClientIDMode="Static">
                        <ProgressTemplate>
                            <span class="progressspan">
                                <img src="../Images/ajax-loader.gif" alt="" />
                                <label>
                                    Please Wait . . .
                                </label>
                            </span>
                        </ProgressTemplate>
                    </asp:UpdateProgress>

                </ContentTemplate>
            </asp:UpdatePanel>

和源代码:

           protected void RequestDocGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        switch (e.CommandName)
        {
            case "Insert":
              ... 

                break;
            case "Delete":

              ...

                break;

            case "Edit":
               ...

                break;

            default:
                break;
        }
    }
    protected void btnInsert_Click(object sender, EventArgs e)
    {
      ....
    }

    protected void btnEdit_Click(object sender, EventArgs e)
    {
      ....
    }
4

2 回答 2

0

在 Telerik 控件的 itemtemplate 中使用 asp 控件时,我也遇到了同样的问题

使用System.EventArgs而不仅仅是EventArgs

对于 btnInsert_Click:

 protected void btnInsert_Click(object sender,System.EventArgs e)
        {
          ....
        }

对于 btnEdit_Click:

protected void btnEdit_Click(object sender, System.EventArgs e)
    {
      ....
    }
于 2013-10-14T07:16:15.043 回答
0

它通过用“RadAjaxPanel”替换“UpdatePanel”来解决。

于 2013-11-27T07:24:46.453 回答