querystring to a hyperlink in vb.net or maybe another solution
I am new to vb.net. Let me explain the two aspx pages that i have. First one is a table with results populated from the sql server backend. The first holds the "FirstNa开发者_StackOverflow社区me". I want this to have a hyperlink, so when i click on this, it should goto the second aspx page and show all the data in sql server for that "Firstname". the data is in 3 other tables based on firstname, which is phone, address and hobbies. So -
FirstName
Samuel --> clicked on it
redirect to second page -
Samuel -
Phone Address Hobbies
3104445656 123 main st Climbing
Please tell me if i need a querystring or is there another solution (better solution). Also how do i capture the querystring in second page?
You can generate a link(href) that goes to
secondpage.aspx?firstname=Samuel
and in the code for the second page you can retrieve this value via Request.Querystring("firstname"). But with webforms and postbacks there are other ways of doing this. After getting the selected firstname (preferably in a variable) you can use it for whatever data retrieval methods you want.
Also, I really would recommend against using the name as a key in your database. If this is an experiment to learn, I guess it doesn't matter, but the second you want to enter two people named "John" into your database you have run into trouble.
I would recommend to use session state instead of querystrings. Or use cross page posting if you are working with .NET 3.5.
Because of security issues, I only use querystrings for non critical data, like for example pagination.
One remark though: Why don't you work with one aspx page to build this functionality?
Chris
精彩评论