How to update label control on the page using QueryStringParameter value?

362 views Asked by At

I am using the QueryStringParameter to pass a parameter in the SELECT statement to display only the necessary data on the page from SQL Server.

<SelectParameters>
    <asp:QueryStringParameter Name="doc_family" QueryStringField="doc_family" Type="String" />
</SelectParameters>

I was wondering what if I could take advantage of the QueryStringParameter and write some IF statements to add custom headings as per data fetched on the page instead of one generic one. As an example:

  1. If (doc_family = CR) then display "Clean Room" on the page
  2. If (doc_family = QA) then display "Quality Assurance" on the page
  3. If (doc_family = TP) then display "Test Protocol" on the page
  4. Else "Page name is not available"

Here is the code snipped for the ASP label control wrapped in H1 tag:

<h1 style="color:Black;">
    <asp:Label ID="DocumentNameLabel" runat="server" Text="Hello World" />
</h1>

My project is written in C# and the QueryStringParameter is used in this format in the URL ~/ProceduresForms.aspx?doc_family=CR.

Any help is appreciate.

1

There are 1 answers

0
eselk On BEST ANSWER

In Page_Load:

if(Request.QueryString["doc_family"] == "CR") DocumentNameLabel.Text = "CleanRoom";

You should be able to take it from there?