与UpdatePanel的GridView控件与LinkBut​​ton的使用Image导致完全回发 [英] UpdatePanel with GridView with LinkButton with Image Causes Full Postback

查看:130
本文介绍了与UpdatePanel的GridView控件与LinkBut​​ton的使用Image导致完全回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这可能是一个相当具体的问题,但我想我会发布它,因为我花了几个小时与它奋斗,我能够确定病因之前。

So this might be a fairly specific issue but I figured I'd post it since I spent hours struggling with it before I was able to determine the cause.

<asp:GridView ID="gvAttachments" DataKeyNames="UploadedID" AutoGenerateColumns="false" OnSelectedIndexChanged="gvAttachments_SelectedIndexChanged" runat="server">
    <EmptyDataTemplate>There are no attachments associated to this email template.</EmptyDataTemplate>
    <Columns>
        <asp:TemplateField ItemStyle-Width="100%">
            <ItemTemplate>
                <asp:LinkButton CommandName="Select" runat="server"><img src="/images/icons/trashcan.png" style="border: none;" /></asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

在GridView的模板列的ItemTemplate中我有一个LinkBut​​ton与它内部的图像。通常我这样做时,我有一个形象的一些文字旁边,但这个时候,不管是什么原因,我只是有图像。这将导致在UpdatePanel总是做一个完整的回发。

In the ItemTemplate of the TemplateField of the GridView I have a LinkButton with an image inside of it. Normally I do this when I have an image with some text next to it but this time, for whatever reason, I just have the image. This causes the UpdatePanel to always do a full postback.

推荐答案

更改LinkBut​​ton的是一个ImageButton的,问题就解决了​​。

Change the LinkButton to be an ImageButton and the problem is solved.

<asp:ImageButton ImageUrl="/images/icons/trashcan.png" Style="border: none;" CommandName="Select" runat="server" />

这篇关于与UpdatePanel的GridView控件与LinkBut​​ton的使用Image导致完全回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆