50分求 删除代码 能用就散分 win 鼠标用dtatgird自带的按钮选中一行 用Button按钮来删除该行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DataTableName.Rows[DataGridName.CurrentRowIndex].Delete(); cpp2017(慕白兄) DataTableName是什么啊 我用datagird来代替它说不行 DelData(Convert.ToInt32(dataGrid1[dataGrid1.CurrentCell.RowNumber,0]));新建一个函数,然后获取你所选择的行的ID号,然后根据该ID号删除这一行,把ID号作为参数传递给函数DelData(); // .aspx<asp:datagrid ...<columns><asp:templatecolumn><itemtemplate><asp:button CommandName=Delete CommandArgument=<%# Eval("主键列") %> ...// .aspx.cs... _DeleteCommand(...{ object key = e.CommandArgument; // 你的具体删除代码 } 问题是获取该ID怎么获取 对Datagird不懂 我是菜鸟 老兄 那是web的代码 我要的是win的 我借cpp2017(慕白兄) 老兄的代码DataTableName.Rows[DataGridName.CurrentRowIndex].Delete();DataTableName//表名,DataGrid是绑定在表上的,或者查询语句返回的数据集(和临时表性质一样)DataGridName//DataGrid控件名,DataGridName.CurrentRowIndex//数据在表中行数索引这样做是用DataAdapter把数据填充到DataSet的表中 控件再绑定表最后要记得调用DataAdapter.Update();把修改的数据更新到数据库 Convert.ToInt32(dataGrid1[dataGrid1.CurrentCell.RowNumber,0])这一句就是获得ID值啊 private void dg1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e){ if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //删除确认 LinkButton delBttn = (LinkButton) e.Item.Cells[4].Controls[0]; delBttn.Attributes.Add("onclick","javascript:return confirm('确定删除?');"); e.Item.Attributes.Add("onmouseover","tdOver(this)"); e.Item.Attributes.Add("onmouseout","tdOut(this)"); }}private void dg1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e){ string id=e.Item.Cells [0].Text.Trim ();//获取员工编号 string sqlstr="delete tab_backip where id='"+id+"'"; data1.moddata (sqlstr); Response.Redirect ("backip_q.aspx");} vs2005运行.asp页面的错误~~~~~ iframe 里面的fckedit在开发环境正常,发布到window 2003 服务器上出现如下问题,请高手指教! 有关object sender的问题 求控件 请求一个简单的网页窗体操作的问题 Asp.net中如何生成静态页面&分页 请教:怎样才能固定表格单元格的宽度和高度(不随内容变化而变化) 求救,急 .aspx 和 .cs 文件的问题 请问如何在sub中打开新窗口? 提一个概念性的问题。。。。求个详细的解释。。。。。。 如何获取服务器端语言??例如 中文版WINDOWS 还是 英文版WINDOWS??
DataTableName是什么啊 我用datagird来代替它说不行
新建一个函数,然后获取你所选择的行的ID号,然后根据该ID号删除这一行,把ID号作为参数传递给函数DelData();
<asp:datagrid ...
<columns>
<asp:templatecolumn>
<itemtemplate>
<asp:button CommandName=Delete CommandArgument=<%# Eval("主键列") %> ...
// .aspx.cs... _DeleteCommand(...
{
object key = e.CommandArgument;
// 你的具体删除代码
}
DataTableName.Rows[DataGridName.CurrentRowIndex].Delete();
DataTableName//表名,DataGrid是绑定在表上的,或者查询语句返回的数据集(和临时表性质一样)
DataGridName//DataGrid控件名,
DataGridName.CurrentRowIndex//数据在表中行数索引
这样做是用DataAdapter把数据填充到DataSet的表中 控件再绑定表
最后要记得调用DataAdapter.Update();
把修改的数据更新到数据库
这一句就是获得ID值啊
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
//删除确认
LinkButton delBttn = (LinkButton) e.Item.Cells[4].Controls[0];
delBttn.Attributes.Add("onclick","javascript:return confirm('确定删除?');"); e.Item.Attributes.Add("onmouseover","tdOver(this)");
e.Item.Attributes.Add("onmouseout","tdOut(this)");
}}private void dg1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string id=e.Item.Cells [0].Text.Trim ();//获取员工编号 string sqlstr="delete tab_backip where id='"+id+"'";
data1.moddata (sqlstr);
Response.Redirect ("backip_q.aspx");}