I have this data taken from the database. At first I had the relatives name as a link in a label and realized I was going to have difficulty trying to pass along session data to the next page that related to the link as it wasn't like a linkbutton that I could handle a clicking event. So, I tried to add a linkbutton inbetween the two labels of that data. I now create a session variable when the linkbutton is clicked. But the problem is I can't figure out how to pass along which relative was clicked. Since I am going through the database of relatives, what ends up happening is that the last person in the database ends up being the name that gets put into the session variable.
I hope someone can show me a way to resolve this so that the right name gets passed into the session variable for using on the next page.
Thanks so much in advance.
Here is what I tried first:
Here is when I tried to use a linkbutton instead:Code:while (reader.Read()) { //Don't print out the hr before the first relative if(cntr != 1) Label4.Text += "<hr />"; Label4.Text += "<strong>" + reader["Relation"].ToString() + "</strong>" + ": "; //See this relatives relations Label4.Text += "<a href=\"searchrelatives.aspx\">" + reader["RelativeFN"].ToString() + " " + reader["RelativeLN"].ToString() + "</a>" + "<br />"; //create session variable to pass along who the relative is Session["ChosenRelative"] = reader["RelativeFN"].ToString() + reader["RelativeLN"].ToString(); if (reader["RelativeBP"].ToString() != "") Label4.Text += "Birth Place: " + reader["RelativeBP"].ToString(); if (reader["RelativeEmail"].ToString() != "") Label4.Text += " | e-Mail: " + reader["RelativeEmail"].ToString(); if (reader["RelativeIM"].ToString() != "") Label4.Text += " | Instant Messenger Handle: " + reader["RelativeIM"].ToString() + "<br />"; //See this relatives relations //Label4.Text += "<a href=\"searchRelatives.aspx\">" + + "</a>"; //Index the counter cntr += 1; }
Code:while (reader.Read()) { //Don't print out the hr before the first relative if(cntr != 1) Label4.Text += "<hr />"; Label4.Text += "<strong>" + reader["Relation"].ToString() + "</strong>" + ": "; //See this relatives relations chsnRltvLnkBttn.Text = reader["RelativeFN"].ToString() + " " + reader["RelativeLN"].ToString() + "<br />"; if (reader["RelativeBP"].ToString() != "") lbl5.Text += "Birth Place: " + reader["RelativeBP"].ToString(); if (reader["RelativeEmail"].ToString() != "") lbl5.Text += " | e-Mail: " + reader["RelativeEmail"].ToString(); if (reader["RelativeIM"].ToString() != "") lbl5.Text += " | Instant Messenger Handle: " + reader["RelativeIM"].ToString() + "<br />"; //See this relatives relations //Label4.Text += "<a href=\"searchRelatives.aspx\">" + + "</a>"; //Index the counter cntr += 1; } The linkbutton code: protected void chsnRltvLnkBttn_Click(object sender, EventArgs e) { //create session variable to pass along who the relative is Session["ChosenRelative"] = chsnRltvLnkBttn.Text; }




Reply With Quote