首页 新闻 会员 周边

GridView不执行RowCommand事件

0
悬赏园豆:10 [已解决问题] 解决于 2009-04-29 11:27

GridView我放了个按钮,可怎么点他都不触发RowCommand事件

 

问题补充: <%@ Page Title="" Language="C#" MasterPageFile="~/Archives/Archives.master" AutoEventWireup="true" EnableEventValidation ="false" CodeFile="ComeOutWith.aspx.cs" Inherits="Archives_ComeOutWith" %><asp:GridView ID="gvArchives" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" Width ="100%" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="1px" CellPadding="1" GridLines="Horizontal" PageSize="20" onrowcommand="gvArchives_RowCommand"> <RowStyle BackColor="White" ForeColor="#333333" /> <Columns> <asp:TemplateField> <ItemTemplate> &nbsp; <asp:Image ID="Image1" runat="server" ImageUrl="~/Image/tit-ico2.gif" /> </ItemTemplate> <ItemStyle Width="3%" /> </asp:TemplateField> <asp:TemplateField HeaderText="序号" SortExpression="ID" InsertVisible="False"> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# GetById()%>'></asp:Label> </ItemTemplate> <ItemStyle Width="5%" /> </asp:TemplateField> <asp:TemplateField HeaderText="标题" SortExpression="Title"> <ItemTemplate> <a href=""> <asp:Label ID="Label1" runat="server" Text='<%# Eval("Title") %>'></asp:Label></a> </ItemTemplate> <ItemStyle Width="45%&
杨杰828的主页 杨杰828 | 初学一级 | 园豆:160
提问于:2009-04-27 09:43
< >
分享
最佳答案
0

楼主,你是不是在web.config里把viewstate禁用了.如果是的话在页面里单独开起来就好了.
<%@ Page Title="" Language="C#" MasterPageFile="~/Archives/Archives.master" AutoEventWireup="true" EnableEventValidation ="false" CodeFile="ComeOutWith.aspx.cs" Inherits="Archives_ComeOutWith" EnableViewState="true" %>

或者是你每次回发都重新绑定了数据,如果是的话,你绑定数据应该加在:
if(!IsPostBack){
//databind
}

I,Robot | 大侠五级 |园豆:9783 | 2009-04-27 12:11

正解啊。

【行止坐卧丶皆修行】 | 园豆:204 (菜鸟二级) | 2012-03-30 10:08
其他回答(3)
0

没有代码,怎么确定你的错误啊,肯定有,可能是你的某个属性没有设置吧。

邢少 | 园豆:10926 (专家六级) | 2009-04-27 09:49
0

模板列里因放服务端的控件。

喂 、仚 生 | 园豆:175 (初学一级) | 2009-04-27 09:50
0

放个CommandTemplate试试。

Azuresong | 园豆:3565 (老鸟四级) | 2009-04-27 10:28
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册