Gridview行内的UpdateProgress和UpdatePanel

时间:2013-07-15 11:39:54

标签: asp.net asp.net-ajax

我在Gridview行TemplateField中有一个带有UpdateProgress,UpdatePanel和Linkbutton的Gridview。当我单击Linkbutton时,UpdateProgress应该可以工作,但不是我的情况。

以下是代码:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
                AutoGenerateColumns="False" BackColor="White" BorderColor="#CC9966"
                BorderStyle="None" BorderWidth="1px" CellPadding="4" DataKeyNames="CustomerID"
                onpageindexchanging="GridView1_PageIndexChanging" Width="500px"
                onrowcommand="GridView1_RowCommand"
                onrowdatabound="GridView1_RowDataBound">
                <Columns>
                    <asp:BoundField DataField="CustomerID" HeaderText="Customer ID" />
                    <asp:BoundField DataField="CompanyName" HeaderText="Company" />
                    <asp:BoundField DataField="City" HeaderText="City" />
                    <asp:TemplateField>
                        <ItemTemplate>

                            <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel2" >
                                    <ProgressTemplate>
                                            <asp:Image ID="Image1" runat="server" ImageUrl="~/images/ajax-loader.gif" />
                                    </ProgressTemplate>
                                </asp:UpdateProgress>

                            <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode= "Conditional" >
                                <ContentTemplate>
                                    <asp:LinkButton ID="lbtnExecute" runat="server" CommandArgument="<%# ((System.Web.UI.WebControls.GridViewRow)(Container)).DataItemIndex + 1 %>"
                                        CommandName="Execute">Execute</asp:LinkButton>
                                </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="lbtnExecute" EventName="Click" />
                                </Triggers>
                            </asp:UpdatePanel>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
                <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
                <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
                <RowStyle BackColor="White" ForeColor="#330099" />
                <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
                <SortedAscendingCellStyle BackColor="#FEFCEB" />
                <SortedAscendingHeaderStyle BackColor="#AF0101" />
                <SortedDescendingCellStyle BackColor="#F6F0C0" />
                <SortedDescendingHeaderStyle BackColor="#7E0000" />
            </asp:GridView>

我尝试删除:

AssociatedUpdatePanelID="UpdatePanel2"

但UpdateProgress显示在所有行中。我希望它只显示在我点击Linkbutton的行上。

有人可以帮忙吗?

0 个答案:

没有答案