listBox1.Items.Remove(listBox1.Items[i]);
解决方案 »
- C#如何连接SQL查询时间段内容
- 各位高手,心电图R波查找算法???
- webbrowser或 axwebbrowser页面元素在屏幕的位置?
- 请教:c#中管random随机函数得到的数据时一样的
- 请教C#的Socket问题
- 跪求vs2008中*.aspx.cs不能找到.aspx中控件的问题
- 请教一个SendKeys.SendWait("{Prtsc}")的问题
- Struct与Class
- 求教。。。。麻烦。。。关于From的Close的。
- MessageBox.Show里的MessageBoxIcon有什么别的值吗?可以自定义图片吗?
- 为了积分啊 怎么做最快啊
- 不显示删除回复显示所有回复显示星级回复显示得分回复 QQ空间自定义管理如何实现?(版式/布局,模块,风格,自定义装扮,一键装扮)
同意楼上
有数据库也需要删除
数据库 delete from [table] where
删除行号为0的行
第一行 修改 删除
第二行 修改 删除
第三行 修改 删除
在页面里面添加一个LinkButton 控件
<asp:LinkButton ID="lbtn_dalete" runat="server" CssClass="btnDelete" Text="删除" CommandName="newsid"
CommandArgument="<%# Eval(newsid)
%>" OnCommand="lbtn_dalete_Command"></asp:LinkButton>
在后台就是添加啦lbtn_dalete_Command事件
protected void lbtn_dalete_Command(object sender, CommandEventArgs e)
{
int newsid=Convert.ToInt32(e.CommandArgument.ToString());
然后调用BLL 层的业务逻辑方法进行delete 删除操作;
这是首写的 可能大小写有点错误 自己敲下就知道啦
执行delete 操作可能返回一个标示符号,,(各人方法不同,也许你方法没返回值)
成功就要重新进行绑定数据源 例如:bindlist();
或者try{}catch一下 应该不用多说啦
}
{MessageBox.Show("你没有选择任何一行", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}
else
{ DialogResult choice = MessageBox.Show("确定要删除该行吗?", "操作警告!",MessageBoxButtons.YesNo,MessageBoxIcon.Warning);
//如果确定删除,则执行删除操作
if (choice == DialogResult.Yes)
{ string sql = string.Format("DELETE FROM 数据库名 WHERE 条件",(int)listbox1.SelectedItems[0].Tag);
SqlCommand command = new SqlCommand(sql,DBHelper.connection);
int result = 0;//操作结果
try
{DBHelper.connection.Open();
result = command.ExecuteNonQuery();}
catch (Exception ex)
{MessageBox.Show(ex.Message);}
finally
{DBHelper.connection.Close();}
if (result < 1)
{MessageBox.Show("删除失败", "操作结果", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);}
else
{ MessageBox.Show("删除成功","操作结果",MessageBoxButtons.OK,MessageBoxIcon.Information);
FillListView();
}