读书人

本人初学者传参

发布时间: 2011-12-17 23:37:33 作者: rapoo

本人菜鸟,传参
gridView 在编辑列中ItemTemplete中BUTTON点击后到另一个页面 怎样传参

[解决办法]
我想这里的传值包括两个知识点
1. 点击button 时 如何执行相应的事件
2 如何把相应的值绑定上去
下面的代码测试成功
设置GridView1 的commandname =open

C# code
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)    {        string name = e.CommandName;        int index = Convert.ToInt32(e.CommandArgument);        string a = GridView1.Rows[index].Cells[1].Text;         if (name == "open")        {            Response.Redirect("a.aspx?id="+a);         }     }    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)    {        if (e.Row.RowType == DataControlRowType.DataRow)        {            Button bt = (Button)e.Row.Cells[0].FindControl("Button2");            bt.CommandArgument = e.Row.RowIndex.ToString();         }    } 

读书人网 >asp.net

热点推荐