GridView怎么实现页面跳转并将值赋给下个页面的Textbox中
现在已经实现在GridView中修改和删除数据的功能,现在想实现再添加一个控件,利用这个控件来完成页面的跳转并将GridView中的值赋给下个页面的Textbox中???...
现在已经实现在GridView中修改和删除数据的功能,现在想实现再添加一个控件,利用这个控件来完成页面的跳转并将GridView中的值赋给下个页面的Textbox中???
我的代码如下:
namespace WebApplication4
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindDataInfo();
}
}
protected void BindDataInfo()
{
TBL.bl bl = new bl();
GridView1.DataSource = bl.GetTemp_messiList();
GridView1.DataBind();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BindDataInfo();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
string newname = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;
string newstate = ((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text;
TBL.bl bl = new bl();
bl.UpdateTemp_messiList(id, newname,newstate);
GridView1.EditIndex = -1;
BindDataInfo();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
BindDataInfo();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string deleteid = GridView1.DataKeys[e.RowIndex].Value.ToString();
TBL.bl bl = new bl();
bl.DeleteTemp_messiList(deleteid);
GridView1.EditIndex = -1;
BindDataInfo();
}
}
} 展开
我的代码如下:
namespace WebApplication4
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindDataInfo();
}
}
protected void BindDataInfo()
{
TBL.bl bl = new bl();
GridView1.DataSource = bl.GetTemp_messiList();
GridView1.DataBind();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BindDataInfo();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
string newname = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;
string newstate = ((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text;
TBL.bl bl = new bl();
bl.UpdateTemp_messiList(id, newname,newstate);
GridView1.EditIndex = -1;
BindDataInfo();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
BindDataInfo();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string deleteid = GridView1.DataKeys[e.RowIndex].Value.ToString();
TBL.bl bl = new bl();
bl.DeleteTemp_messiList(deleteid);
GridView1.EditIndex = -1;
BindDataInfo();
}
}
} 展开
2个回答
展开全部
给你举个例子吧:
<asp:HyperLink Text='<%# Eval("Title") %>' NavigateUrl='<%# Eval("id","TopicReply2.aspx?topic_id={0}") %>' ID="HyperLink1" runat="server" />
添加HyperLink列,这句话的意思是把id(数据库表中的一列名)的值传赋值给topic_id,然后把topic_id在跳转到TopicReply2的过程中传递过去,在Topic_id页面中用 函数接收就OK了
<asp:HyperLink Text='<%# Eval("Title") %>' NavigateUrl='<%# Eval("id","TopicReply2.aspx?topic_id={0}") %>' ID="HyperLink1" runat="server" />
添加HyperLink列,这句话的意思是把id(数据库表中的一列名)的值传赋值给topic_id,然后把topic_id在跳转到TopicReply2的过程中传递过去,在Topic_id页面中用 函数接收就OK了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
编辑列,有个hyperLink列。里面有个什么。。。Url属性,最长那个
值设为xxxx.aspx?id={0}//0为第一列
下个页面
textbox1.Text=Requsest.Query["id"].ToString();
值设为xxxx.aspx?id={0}//0为第一列
下个页面
textbox1.Text=Requsest.Query["id"].ToString();
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询