<asp:GridView ID="GridView1" runat="server" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging" PageSize="3" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound" >
<Columns>
<asp:ButtonField ButtonType="Button" CommandName="del" Text="刪除" />
</Columns> </asp:GridView>在后台本意是给他添加了一个前台事件 myButton.Attributes.Add("onclick","return del()");结果前台事件是执行了,但后台事件不执行了
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "del")
{
Response.Write("<script>alert('" + e.CommandArgument.ToString() +"')</script>");
}
}为什么?根本就不执行这个事件了
<Columns>
<asp:ButtonField ButtonType="Button" CommandName="del" Text="刪除" />
</Columns> </asp:GridView>在后台本意是给他添加了一个前台事件 myButton.Attributes.Add("onclick","return del()");结果前台事件是执行了,但后台事件不执行了
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "del")
{
Response.Write("<script>alert('" + e.CommandArgument.ToString() +"')</script>");
}
}为什么?根本就不执行这个事件了
解决方案 »
- List<Object>集合绑定AspnetPage
- 如何实现非page_load的datalist分页功能
- 怎样把当前用户的profile显示在label上?
- 在线播发器的问题!
- table.banner? navigation?
- vs2005,c#,请问,如何在dataset(datatable也可)里面新增一行?
- 一个关于float类型的问题~
- 哪位大侠给份完整的分页代码,
- 能不能用DataTable类实现身份验证安全登陆?
- 怎么会出现 System.NullReferenceException 我用的vb
- |zyciis| C#基础问题 如何继承enum 谢谢
- 哪里可以申请支持asp.net 2.0 的 免费 空间
Button myButton = (Button)GridView1.FindControl("ButtonName"); ??
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "del")
{
//执行删除操作
}
}
Button myButton = e.Row.FindControl("ButtonName") as Button;
myButton.Attributes.Add("onclick","return confirm('是否真的删除?');");
我在protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 这里设了断点,根本没有执行到这来
打错了,是这样还是不行 TableCellCollection myCells = e.Row.Cells;
Button myButton = (Button)myCells[0].Controls[0];
myButton.Attributes.Add("OnClick", "return confirm('是否真的刪除?');");