在另一页上检索datagrid的值 [英] Retrieving values of datagrid on another page
本文介绍了在另一页上检索datagrid的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将值从一页的gridView传递到另一页的文本框
我写了以下代码
第一页:
I am trying to pass values from gridView of one page to a textbox of another page
I have written following code
On first page:
foreach (GridViewRow row in dgvSearchResults.Rows)
{
string name = row.Cells[1].Text;
string time = row.Cells[2].Text;
Response.Redirect("EmpDetails.aspx?name=" + name.ToString());
}
在第二页上:
on second page:
this.txtPatientName.Text = Request.QueryString["name"].ToString();
当我尝试执行此操作时,出现以下错误:
When I am trying this to do,I am getting following error:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 108: protected void Page_Load(object sender, EventArgs e)
Line 109: {
Line 110: this.txtName.Text = Request.QueryString["name"].ToString();
Line 111: }
Line 112: }
问题出在哪里?
Where is the problem?
What should i need to do to solve this?
推荐答案
在第二页上尝试以下代码:
Try this code on second page:
if (Request.QueryString["name"]!=null && !string.IsNullOrEmpty(Request.QueryString["name"].ToString()))
{
this.txtName.Text = Request.QueryString["name"].ToString();
}
否则,请在此处浏览一下 [
Or else have a look here[^]
您可以使用跨页发布来访问另一个数据库中的DataGrid值页.看看:
msdn.microsoft.com/en-us/library/ms178139.aspx
You can use Cross-Page Posting to access DataGrid value in another page. Have a look:
msdn.microsoft.com/en-us/library/ms178139.aspx
这篇关于在另一页上检索datagrid的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文