当前位置: 代码迷 >> ASP.NET >> help:怎么自定义 gridview控件本身的button 事件?
  详细解决方案

help:怎么自定义 gridview控件本身的button 事件?

热度:4076   发布时间:2013-02-26 00:00:00.0
help:如何自定义 gridview控件本身的button 事件???


<asp:GridView   ID= "grdv1 "   runat= "server "   AutoGenerateColumns= "False "  
Width= "800px "   Height= "255px "   AllowPaging= "True "   AllowSorting= "True "   OnPageIndexChanging= "grdv1_PageIndexChanging "   >
<Columns>
<asp:ButtonField   ButtonType= "Button "   Text= "约定此课 "   CommandName= "oncl "   />
</Columns>
</asp:GridView>

     
  public   void   oncl(Object   sender,   GridViewCommandEventArgs   E)
        {  
                        string   strconn=   ConfigurationSettings.AppSettings[ "ConnectionString "];
                        SqlConnection   cn   =   new   SqlConnection(strconn);
..............等等   数据库操作
        }

但是点完gridview上的button后   事件无响应  
我想做的是数据插入操作..所以   CommandName   没用SELECT   EDIT   UPDATE   属性   所以需要自定义
请高手指点!!!

------解决方案--------------------------------------------------------
你的思路有问题,你要自定义事件的话,那你要先自己写一个GridView ,继承现有的GridView ;
可是你的要求我看不出来有这个必要啊
  相关解决方案