在后台代码中定义了datagrid的列,其中有一列为buttoncolumn,我把这一列指定为删除按钮,我想问一下怎么实现当点击每一个删除按钮时能弹出删除页面,该页面问是否要删除xx产品?其中某某产品的名称是从从数据库中读出的字段product_id?
解决方案 »
- RDLC 出现#ERROR
- 今天理顺了下网站、bs和cs的关系
- 谁能帮我下啊!
- 关于DataGrid数据邦定的问题,请教高手!
- 在form1中的timer_click事件中,每隔5秒给form2中的label1中赋值,请大家帮个忙?
- 1 4 20 52 110 209
- FTP协议中用LIST命令不能完全收到返回信息???
- 谁能贴点代码给我:点击datagrid 的某行在combobox中显示当前行的某个字段的名称。谢谢!!!!
- 如何确定我的软件的架构?
- 在c#,怎么无线访问远端数据库啊,知道的朋友近来帮帮忙!
- 纯属研究方法,代码难实现.MSN的MAGIC表情和QQ魔法表情宠物秀的实现.
- 关于文件管理的思路!
http://www.codeproject.com/aspnet/NingLiangSimpleControl.asp
来弹出对话框,以求确认,再处理。
Button btnDelete = (Button)e.Item.FindControl("btnDelete");
btnDelete.Attributes.Add("onclick","JavaScript:return confirm('确认删除吗?');");
以上两句用来处理探出删除窗口的问题。具体的删除该条记录得进行相应的数据操作,然后重新绑定一下
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button Runat="server" Text="删除" ID="btnDelete"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
string s_proid;
s_str=String.Format("<script>alert('目前你选择的设备数量最大不能超过:{0}')</script>",
s_proid);
Page.RegisterStartupScript("new",s_str);
当然 上面的代码应放在模板按纽列的触发事件里
{
switch(e.Item.ItemType)
{
case ListItemType.Item:
case ListItemType.AlternatingItem:
case ListItemType.EditItem:
{ LinkButton btnDelete=(LinkButton)e.Item.FindControl("btn_del"); btnDelete.Attributes.Add("onclick", "return confirm('你是否确定删除?');");
break;
}
}
}
{
string js = string.Format("<script language='JavaScript'>javascript:window.showModelessDialog(\"{0}&rand="+new Random().Next().ToString()+ "\",window,\"status:false;dialogWidth:{1}px;dialogHeight:{2}px\");</script>",openAspxPage,width,height);
return js;
}
这个函数弹出一个非模态窗口,使用的时候Response.Wrint()出来,openAspxPage是你要弹出的那个窗口
-------------------------------------------------
删除前弹出“确定?”,一般也是这么用的:
前台用
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button Runat="server" Text="删除" ID="btnDelete"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
在datagrid的DataGrid1_ItemDataBound事件中写入:
if(e.Item.FindControl("btnDelete1")!=null)
{
((Button)e.Item.FindControl("btnDelete")).Attributes.Add("onClick", "return confirm('你确定要删除这一项吗?');");
}
--------------------------------------------------------
要实现你所说的功能,稍微改动一下就行了:
string ss= "******"; // 从数据库中读到的数据;
将“ ((Button)e.Item.FindControl("btnDelete")).Attributes.Add("onClick", "return confirm('你确定要删除这一项吗?');"); ”改为:
((Button)e.Item.FindControl("btnDelete")).Attributes.Add("onClick", "return confirm('"+ss+"');");