Hi, I have a project I am currently working on that generates reports for users. At the minute the reports appear in a menu and when selected it directs the user to a page for that report. However I have been asked to change it to allow flexibility. So now I have to have only one page and when a report is selected it will appear on the same page. Someone mentioned something about querystrings but I'm not overly familiar. If someone could help it would be great. When the user selects a report it fires a method that accesses the stored procedure and returns the data needed. Not sure how I can do this with the new way either. Thanks in advance.
To use query strings you make use of the
Request.QueryString method assuming of course that this is WebForms and not MVC. So for example, consider that you have a Default.aspx page and a Report.aspx page. On the Default.aspx page you might have two basic links:
<a href="Report.aspx?ReportID=100" /><br /> <a href="Report.aspx?ReportID=200" /><br />
Note in these links that it uses the ? character followed by a key/value pair. This is the query string. A query string can have more key/value pairs than that present above and if it does then they are separated with the & character. For example:
<a href="Report.aspx?ReportID=100&Language=English>Report 100</a>
In the Report.aspx page, when you want to grab any values from the query string in the code behind you would use:
Dim reportId As String = Request.QueryString("ReportID")
So assuming that you have one stored procedure to get the data required for the report and it needs some form of ID passed as a parameter you could use the above to supply that value to the stored procedure and have one page display the report.