C# DataList控件 按钮传值 急急急!!!!
来源:百度知道 编辑:UC知道 时间:2024/05/16 01:16:22
拜托我是DataList 不是GridView,而且是Button,不是LinkButton。不是激动 是强调!
先谢谢各位了。。
激动什么?
处理RowDataBound和RowCommand事件
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.DataItem != null)
{
LinkButton sButton0 = (LinkButton)e.Row.Cells[1].Controls[0];
sButton0.CommandName = "select1";
sButton0.CommandArgument = ((DataRowView)e.Row.DataItem).Row["id"].ToString();
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "select1")
{
this.Response.Redirect("~/XXX.aspx?id=" + e.CommandArgument);
}
}
代码我就不写了 我给你分析下
DataList 放一个按钮控件
DataList 可以用数组遍历里面的值
当发现哪个一个值是选中状态的时候
调用它的事件方法就行了 要写的方法就是
所要跳转的页面
<asp:Button ID="Button1