| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 752 人关注过本帖
标题:删除按钮不起作用
取消只看楼主 加入收藏
baozishi
Rank: 1
来 自:重庆
等 级:新手上路
帖 子:31
专家分:0
注 册:2007-10-13
收藏
 问题点数:0 回复次数:1 
删除按钮不起作用
我用的是在Datagrid中删除..但点击它不起作用..
事件代码是:
public void stugrid_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{     Response.Write("lll");

    if(stugrid.Items.Count==1)
        {
        if(stugrid.CurrentPageIndex!=0)
            {
            stugrid.CurrentPageIndex = stugrid.CurrentPageIndex-1;
            }
        }
    stugrid.DataKeyField="time";
    string id = this.stugrid.DataKeys[e.Item.ItemIndex].ToString(); //定义数据健,取得ID
    SqlConnection con = new SqlConnection("server=(local);user id=sa;password=sql;database=datac;");
    SqlCommand com = new SqlCommand("delete from datainfo where time=@time",con);
    com.Parameters.Add ("@time",SqlDbType.DateTime ,10);
    com.Parameters ["@time"].Value =id;
    con.Open();
    com.ExecuteNonQuery();
    BindGrid();
}


在DATAGRID中:
<asp:datagrid id="stugrid" runat="server" AutoGenerateColumns="false" OnEditCommand="stugrid_Edit"

OnUpdateCommand="stugrid_Update" OnCancelCommand="stugrid_Cancel" OnButtonCommand="stugrid_DeleteCommand" >
列控件在上面的DATAGRID中,代码是:
<asp:ButtonColumn
    ButtonType="LinkButton"
    CommandName="Delete"
    HeaderText="删除"
    Text="删除"
    Visible="True"/>
搜索更多相关主题的帖子: 按钮 删除 
2007-12-18 18:31
baozishi
Rank: 1
来 自:重庆
等 级:新手上路
帖 子:31
专家分:0
注 册:2007-10-13
收藏
得分:0 
我定义的是当前系统时间为主键..
它的属性是:DateTime
2007-12-18 18:32
快速回复:删除按钮不起作用
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019530 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved