R – hyperlink in asp.net that takes the value to the next page

hyperlinksession-variablesvb.net

im using asp.net with vb.net in backcode. On my first page, i diplay names of all employees. I want to give that a hyperlink, that when clicked upon shall open the next page with say a querystring and opn only that employees records. Also I want the save the employeeid (which is not shown on page 1) on the second page, cause when i do updates on second page, I want to use that employeeId in "where" clause for update or insert statements.
any ideas?

Best Answer

If you're not concerned about people messing the with query string you can use that and then just get the data out in the next page during the Page_Init or Page_Load using:

HttpContext.Current.Request.Item("EmployeeID")

However, I'm a fan of not using the query string because people tamper with it. You can use the PostBackUrl property of your hyperlink (if you use the asp linkbutton), and in the next page you can use the Page.PreviousPage object to access any objects from the previous page.

<asp:LinkButton ID="lnkEmployeeLink23232" runat="server" CommandArgument="23232" PostBackUrl="NextPage.aspx" Text="Employee Name" />

You'll have to check for IsCrossPagePostBack on the first page to make sure you don't fire databinding unnecessarily, but at that point you should be able to get to the control that fired the postback and from there get the command argument which would be the employee id in question.4

http://msdn.microsoft.com/en-us/library/ms178139.aspx http://www.developerfusion.com/code/4687/cross-page-postbacks-in-aspnet-20/