asp.net gridview的一个bug解决办法
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
欢迎访问http://www.computerj.com 电脑街!
<ItemTemplate>
<asp:ImageButton runat=server id="ImageButton1" CommandName="Delete"
ImageUrl="" commandargument='<%# DataBinder.Eval(Container,
"RowIndex") %>' OnCommand="ImageButton1_Command" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void ImageButton1_Command(object sender, CommandEventArgs e) {
GridView1.DeleteRow(Int32.Parse(e.CommandArgument.ToString()));
}
把imagebuttong加入到TemplateField中,并且在事件中调用deleterow。不知道还有没有更好的解决方案,下面的论坛详细的讨论了这个问题:
http://www.developersdex.com/asp/message.asp?p=1116&r=4641456&page=2第一页讨论的结果是:只有在button的类型是image的状况下才会有此问题,可以略过不看,后面两页有详尽的讨论和解决方式。
今天一天一直在遇到奇怪问题,头大了,相同的代码经常一会可以执行,一会儿不可以,vs2005也一直出怪事。刚才把下午不能运行的几个问题在家模拟了一下竟然运行良好!!明天又要头痛了
