Using hyperlink to pass info

  • Thread starter Thread starter Jim McGivney
  • Start date Start date
J

Jim McGivney

From a DataGrid on Page1.aspx I use a hyperlink button to open a new page
named Page2.aspx.

I would like the new page to respond to the hyperlink by displaying text in
a label box.
The hyperlink's Text Format String is: Page1.aspx?MI={0}

This is my code for the new page load event.

private void Page_Load(object sender, System.EventArgs e)
{
string mi = Request.QueryString["MI"];
this.Label1.Text = mi.ToString();
}

It builds without problem, but when the hyperlink is pressed, I get the
error: Object reference not set to an instance of an object
and the indicated line is: this.Label1.Text = mi.ToString();

Any help would be appreciated.

Thanks,

Jim
 
try this:

private void Page_Load(object sender, System.EventArgs e)
{
string mi = Request.QueryString["MI"].ToString();
this.Label1.Text = mi;
}
 
Back
Top