日期:2014-05-16  浏览次数:21164 次

为什么Gridview中的OnRowCommand函数始终不被触发,调试了根本就没进入_RowCommand函数
下面是前台代码:
    <asp:GridView ID="gvGetFile" runat="server" AutoGenerateColumns="False" Width="100%" EmptyDataText="无数据" OnRowDataBound="gvGetFile_RowDataBound"
                    OnRowCommand="gvGetFile_RowCommand" AllowSorting="true" DataKeyNames="dfName" >
                  <RowStyle HorizontalAlign="Center" />
            <Columns>
                <asp:HyperLinkField DataTextField="dfName" HeaderText="档案文件名称" HeaderStyle-CssClass="TdTitle"
                     DataNavigateUrlFields="dfName" DataNavigateUrlFormatString="~/Upload/Archives/{0}"  Target="_blank" />
                <asp:BoundField DataField="dfTime" HeaderText="上传日期" HeaderStyle-CssClass="TdTitle" />
                <asp:ImageField DataImageUrlField="imgfType" HeaderText="文件类型" HeaderStyle-CssClass="TdTitle" >     
                </asp:ImageField>
                <asp:BoundField DataField="dfSize" HeaderText="文件大小" HeaderStyle-CssClass="TdTitle" />

                <asp:TemplateField HeaderText="操作" HeaderStyle-CssClass="TdTitle" >   
                <ItemTemplate>   
                   <asp:Button ID="ButtonView" runat="server" Text="在线预览" CssClass="Button" CommandName="btnView" />&nbsp;
                   <asp:Button ID="ButtonDownLoad" runat="server" Text="下载文件" CssClass="Button" CommandName="btnDownLoad" />&nbsp;
                   <asp:Button ID="ButtonDel" runat="server" Text="删除" CssClass="Button" CommandName="btnDelete" />   
                </ItemTemplate>   
                </asp:TemplateField> 
            </Columns>
                  <HeaderStyle CssClass="GVHeader" />
        </asp:GridView>
很急  啊。。。。。
------解决方案--------------------
protected void Page_Load(Object sender, EventArgs e)