Using hyperlink to pass info

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
 
A

Alejandro Penate-Diaz

try this:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top