在datagrid中,我添加了一列用来删除的按钮列,当点击后我要弹出一个(confirm)对话框
代码中 我要怎么写呢???
大哥大姐们 帮帮忙吧 已经郁闷了很久了……
等待中……
代码中 我要怎么写呢???
大哥大姐们 帮帮忙吧 已经郁闷了很久了……
等待中……
解决方案 »
- 求教:typeof(string)是什么意思?为什么()里面是个string?
- 页面没有回发,js使页面变长,如何保持页面的滑动条不回到上面
- 各位大侠出来讲讲 ajax 中的 updatePanel 吧!
- 用过CodeMatic 2.0的朋友请进
- 关于遍历web窗体上的Controls
- 分页出错(问题解决就结贴)
- 急~~~~~~~~~,把文件拷到别人机子上就不行了---System.Data.SqlClient.SqlException: SQL Server 不存在
- 一个页面中有两个提交怎么办?
- MVC3 razer页面中DropDownListFor无法选中问题,求帮助
- 在线等待:请问我如何取出其中的记录呢?
- 请各位一定帮帮忙,很急!!!
- 100分等您帮忙解决问题
//删除时绑定提示脚本,datagrid的ItemDataBound事件
private void dgDept_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemIndex>=0)
{
LinkButton lib=(LinkButton)e.Item.Cells[6].Controls[0]; // 6,按钮列的索引
lib.Attributes.Add("onclick","javascript:return confirm('你确定要删除该部门信息吗?');"); }
}
{
if(e.Item.ItemIndex>=0)
{
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='#FFC080'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'");
LinkButton delBttn = (LinkButton) e.Item.Cells[9].Controls[0];
delBttn.Attributes.Add("onclick","javascript:return confirm('确定删除该条信息吗?');"); }
}
{
if(e.Item.ItemIndex>=0)
{
SqlConnection conn = new SqlConnection(ConfigManager.CurrentDBContext.ConnectionString);
string id=e.Item.Cells[13].Text.ToString();
string delSql="delete employee_subchange where id="+int.Parse(id)+"";
System.Data.SqlClient.SqlCommand mycomm=new SqlCommand(delSql,conn);
try
{
conn.Close();
conn.Open();
mycomm.ExecuteNonQuery(); }
catch(Exception ex)
{
this.Response.Write(ex);
}
finally
{
conn.Close();
mycomm.Dispose();
}
this.SubBind(bindSql2);
}
}
出错了:指定的转换无效
LinkButton lib=(LinkButton)e.Item.Cells[6].Controls[0]; // 6,按钮列的索引
这句错误了
点击了OK后要执行的代码要写在哪里的啊?
答者都给分
....'你的删除代码
End Sub
e.Item.Cells[6].FindControl("控件ID"); //用这个试试