Dear All:
我在DataGrid中加了一列Button,让用户进行删除确认。所以在后台写了如下代码:
Button DelButton = (Button)e.Item.Cells[2].Controls[0];
DelButton.Attributes.Add("onclick", "return confirm('Are you sure to delete this line?');"); 程序可以正常运行,但我们并不能捕获客户是选择的Yes还是NO,所以我的问题是:怎样把DelButton.Attributes.Add("onclick", "return confirm('Are you sure to delete this line?');"); 这段代码写在客户端的HTML里面,而不是写在后台代码中?当用户确认时才提交,否则不提交。Aspx代码如下:
<asp:DataGrid id="CustGrid"......>
<Columns>
........
<asp:ButtonColumn HeaderText="编辑" Text="编辑" ButtonType="PushButton"
HeaderStyle-HorizontalAlign="center"
ItemStyle-HorizontalAlign="center" CommandName="custdelete"/>
</Columns>
</asp:DataGrid>谢谢各位!
Kent
我在DataGrid中加了一列Button,让用户进行删除确认。所以在后台写了如下代码:
Button DelButton = (Button)e.Item.Cells[2].Controls[0];
DelButton.Attributes.Add("onclick", "return confirm('Are you sure to delete this line?');"); 程序可以正常运行,但我们并不能捕获客户是选择的Yes还是NO,所以我的问题是:怎样把DelButton.Attributes.Add("onclick", "return confirm('Are you sure to delete this line?');"); 这段代码写在客户端的HTML里面,而不是写在后台代码中?当用户确认时才提交,否则不提交。Aspx代码如下:
<asp:DataGrid id="CustGrid"......>
<Columns>
........
<asp:ButtonColumn HeaderText="编辑" Text="编辑" ButtonType="PushButton"
HeaderStyle-HorizontalAlign="center"
ItemStyle-HorizontalAlign="center" CommandName="custdelete"/>
</Columns>
</asp:DataGrid>谢谢各位!
Kent
解决方案 »
- .net操作access数据库问题,急急!
- 做过discuz nt 整合ASP.NET的请进
- 搞了我三个多小时的dataset删除行数据小问题~
- repeater加分页,怎么封装成控件?
- 弹出页面的实现?
- 如何在Label中只显示超链接,忽略其他的网页代码
- 如何控制treeview在页面中的位置啊。table不行、div也不行、框架又不好用?拜托了各位!还有什么可以用啊?
- object对象能用变量替换吗?
- 歪了门的一个问题,大家帮助看看.其实很简单的问题.
- 我刚装了.net,但是不能新建文件 我没有看到这方面的贴子 求救!!!!
- 在Sessin中可以保存一个自定义类的实例吗?
- win2000下装了iis5,如何支持asp.net 1.1
你选了no它是不会递交的,选了yes才会运行server端呀
还有问题,可能我的后台代码放的位置不对,麻烦你帮我看看。
我在DataGrid中加了一列Button,让用户进行删除确认。所以在后台写了如下代码:
public void CustGrid_Del (Object sender, DataGridCommandEventArgs e){
.........
Button DelButton = (Button)e.Item.Cells[2].Controls[0];
DelButton.Attributes.Add("onclick", "return confirm('Are you sure to delete this line?');");
.......
} 程序可以正常运行,但我们并不能捕获客户是选择的Yes还是NO,所以我的问题是:怎样把DelButton.Attributes.Add("onclick", "return confirm('Are you sure to delete this line?');"); 这段代码写在客户端的HTML里面,而不是写在后台代码中?当用户确认时才提交,否则不提交。Aspx代码如下:
<asp:DataGrid id="CustGrid"
.......
OnItemCommand="CustGrid_Del" >
<Columns>
........
<asp:ButtonColumn HeaderText="编辑" Text="编辑" ButtonType="PushButton"
HeaderStyle-HorizontalAlign="center"
ItemStyle-HorizontalAlign="center" CommandName="custdelete"/>
</Columns>
</asp:DataGrid>谢谢各位!
DelButton.Attributes.Add("onclick", "return confirm('Are you sure to delete this line?');");这段代码应该写在item_create事件中吧
在ItemDataBound事件中绑定js