我正在使用此代码,但这不起作用..
1。当我从此代码中删除更新面板时它将正常工作,但是在更新面板中,此代码无效。 2。我还使用trigger for按钮发送异步请求。
<asp:GridView ID="GridView2" runat="server" ShowFooter="True" AutoGenerateColumns="False"
CellPadding="4" ForeColor="Black" AllowPaging="True"
onpageindexchanging="GridView2_PageIndexChanging"
onrowdatabound="GridView2_RowDataBound"
onselectedindexchanged="GridView2_SelectedIndexChanged"
DataKeyNames="id,date" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
BorderWidth="3px" CellSpacing="2" PageSize="5" GridLines="None">
<Columns>
<%-- <asp:BoundField DataField="date" HeaderText="DATE" DataFormatString="{0:MM/dd/yy}">
--%>
<asp:BoundField DataField="Id" HeaderText="REF. ID">
<ItemStyle BackColor="#33CC33" BorderColor="Maroon" Font-Bold="True"
Font-Italic="True" ForeColor="#CC3300" />
</asp:BoundField>
<asp:BoundField DataField="Name" HeaderText="AUTHO. NAME" />
<asp:BoundField DataField="ItemType" HeaderText="ITEM TYPE">
<HeaderStyle Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="Quantity" HeaderText="QUANTITY">
<HeaderStyle Width="130px" />
</asp:BoundField>
<asp:BoundField DataField="Brand" HeaderText="BRAND" />
<asp:BoundField DataField="SubType" HeaderText="SUB TYPE">
<HeaderStyle Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="Date" HeaderText="DATE"
DataFormatString="{0:yyyy-MM-dd HH:mm:ss}">
<HeaderStyle Width="100px" />
</asp:BoundField>
<asp:TemplateField SortExpression="QuantityInPiece" HeaderText="Quantity In Piece" >
<ItemTemplate > <asp:Label ID="lblId" runat="server" Text='<%# Bind("QuantityInPiece") %>'></asp:Label> </ItemTemplate>
<FooterTemplate>
<asp:ImageButton ID="imgbtn_excel_gridout" runat="server"
ImageUrl="~/images/excel.jpg" Width="20px" Height="15px"
onclick="imgbtn_excel_gridout_Click">
</asp:ImageButton>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCCCC" BorderStyle="Solid" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
<SortedAscendingCellStyle BackColor="#E9E7E2"></SortedAscendingCellStyle>
<SortedAscendingHeaderStyle BackColor="#506C8C"></SortedAscendingHeaderStyle>
<SortedDescendingCellStyle BackColor="#FFFDF8"></SortedDescendingCellStyle>
<SortedDescendingHeaderStyle BackColor="#6F8DAE"></SortedDescendingHeaderStyle>
</asp:GridView>
<br />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="imgbtn_excel_gridout" />
</Triggers>
</asp:UpdatePanel>
答案 0 :(得分:0)
您可以尝试在此处完成此方法:
ASP.NET - Adding an UpdatePanel trigger to a LinkButton inside a gridview
使用ImageButton控件而不是LinkButton。