且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将值从datagrid传递到另一个页面

更新时间:2022-05-09 22:22:46


在下面尝试此代码
Hi,
Try this code below
if (Request.QueryString["name"]!=null && !string.IsNullOrEmpty(Request.QueryString["name"].ToString()))
{
    this.txtPatientName.Text = Request.QueryString["name"].ToString();
}



在第一页上,为什么每个gridview行都将名称值重定向到另一页?在这种情况下,它将无法工作,基于某些事件/业务逻辑会发生重定向.考虑一下,希望这将解决您的对象引用错误.



And on first page why each gridview row is redirecting name value to other page? In this case it wont work, redirection happen based on some event/business logics. Give this a thought.Hope this will solve your Object reference error.


以datakey作为名称,并在gridview中使用gridview Delete命令,并根据您的需要更改delete命令的文本名称. >
Take datakey as name and take gridview deleting command in gridview and change text name of delete command as per you.
protected void EmployeeGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
    string Name= EmployeeGridView.DataKeys[e.RowIndex].Value.ToString();
    Response.Redirect("AddPatients.aspx?EmployeeId=" + Name);
}






然后在下一页的加载事件中
做某事






then on load event of next page
do something

protected void Page_Load(object sender, EventArgs e)
    {  string Name= Request.QueryString["Name"];
        this.txtPatientName.Text = Name;
    }


希望 [ ^ ]也可能会为您提供帮助.
Hope this[^] also might help you.