在asp.net gridview的模板字段中单击按钮不适用于更新面板

时间:2013-10-13 09:59:37

标签: c# asp.net telerik updatepanel

我有一个更新面板和一个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)
    {
      ....
    }

2 个答案:

答案 0 :(得分: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)
    {
      ....
    }

答案 1 :(得分:0)

通过将'UpdatePanel'替换为'RadAjaxPanel'来解决。