private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName=="删除")
{
string strSQL="delete FROM yonghuxinxi where ID="+ e.Item.Cells[2].Text.Trim();
//你的删除代码
}
}
{
if(e.CommandName=="删除")
{
string strSQL="delete FROM yonghuxinxi where ID="+ e.Item.Cells[2].Text.Trim();
//你的删除代码
}
}
解决方案 »
- win2008 64位+iis7共享内存问题
- |M| 救命啊 大家帮我看看这个报表啊
- 只能輸入小時分鍾用什麽控件或用什麽正則表達式驗證? 格式如下:hh:mm
- 关于在页面使用类对象的问题?(急!)
- <<<<<<<<<ASP.NET基于角色的权限管理!
- 动态变化的控件序列化
- asp.net程序设计基础下载
- asp.net 自定义标签的属性怎么定义啊 ?
- 如何在datagrid中添加行?
- wpf mvvm技术点,return后面啥意思,请大神
- -----------------datagrid控件button列的响应事件到底是什么?-----------------
- 在.net中可不可以操作xsl.
String strSQL="delete FROM yonghuxinxi where ID="+e.Item.Cells[1].Text.Trim()
String strSQL="delete FROM yonghuxinxi where ID="+(int)DataGrid1.DataKeys[e.Item.ItemIndex];
应先删除后,再用Select * from yonghuxinxi
然后绑定,删除语句同timmy310
String strSQL="delete FROM yonghuxinxi where ID='"+DataGrid1.SelectedItem.Cells[2].Text+"'";
String strSQL="delete FROM yonghuxinxi where ID="+e.Item.Cells[2].Text;
是字符串:
String strSQL="delete FROM yonghuxinxi where ID='"+e.Item.Cells[2].Text+"'";
我试了,这样的确有问题,请问你说的"应先删除后,再用Select * from yonghuxinxi"
要用到2个String strSQL吗?应该怎样写啊?
我这样写
SqlConnection cn=new SqlConnection("data source=NET-001;initial catalog=aspceshi;user id=sa;password=admini");
String strSQL="delete FROM yonghuxinxi where ID=="+e.Item.Cells[3].Text.Trim();
String strSQL1="SELECT ID, PASSWORD, SEX, YONGHUMING FROM yonghuxinxi";
SqlDataAdapter objAdapter= new SqlDataAdapter(strSQL,cn);
SqlDataAdapter objAdapter1= new SqlDataAdapter(strSQL1,cn);
DataSet objDataSet= new DataSet();
objAdapter1.Fill(objDataSet); cn.Close();
DataGrid1.DataSource=objDataSet;
DataGrid1.DataBind();
好象没有删除!
{
SqlConnection cn=new SqlConnection("data source=数据库名;initial catalog=aspceshi;user id=sa;password=admini");
String strSQL="delete FROM yonghuxinxi where ID='"+e.Item.Cells[2].Text+"'";
SqlCommand cmd = new SqlCommand( strSQL,cn );
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
}
我试了一下你的方法说这里
cmd.ExecuteNonQuery();
有语法错误。