Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7851831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:16:28+00:00 2026-06-02T19:16:28+00:00

This shows the patient details page when <a href= /> is clicked (anchor tag

  • 0

This shows the patient details page when <a href="" /> is clicked (anchor tag is inside repeater):

function showPatient(Pid) {                          
    RedirectToPage("Patient_Registration.aspx","pid="+Pid);
    return false;
}
<asp:Repeater ID="repeaterPatientList" runat="server" OnItemDataBound="repeaterPatientList_ItemDataBound" >
    <ItemTemplate>
        <a href="#" onclick="return showPatient('<%#Eval("PID") %>')"><%#Eval("Patient_Name")%></a>
    </ItemTemplate>
</asp:Repeater>

I am getting pID as query string on patient details page. After getting pID on first page load the patient information is filled into the respective text fields. But when I click the save button pID is lost – getting 0 as value so that the insert query always fires.

int pID;
protected void Page_Load(object sender, EventArgs e)
{
    pID = Convert.ToInt32(Request["pid"]);

    if (pID != 0)
    {
        if (IsPostBack == false)
        {
            FillPatientInfo(pID);
        }
    } 
}
protected void btnSave_Click(object sender, EventArgs e)
{
    if(pID ==0)
    {
        //insert query code
    }
    else
    {
        //update query code
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:16:30+00:00Added an answer on June 2, 2026 at 7:16 pm

    You are not using the QueryString – the code in the JavaScript RedirectToPage() method reads the QueryString and outputs it as form elements and then submits to the target page.

    This works fine the first time but as soon as the page posts back the value is lost so this behaviour is correct.

    You should either store the value somewhere (ViewState, Session etc) or add a HiddenField to the page and populate it on first load, then on postback you can pull the value from the HiddenField.

    Edit

    To go the hiddenfield route add a control into your ASPX page like this

    <asp:HiddenField runat="server" ID="hidField" />
    

    And then alter your PageLoad like this

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                pID = Convert.ToInt32(Request["pid"]);
                if(pID != 0)
                {
                    FillPatientInfo(pID);
                    hidField.Value = pID;
                }
            }
            else
            {
                pID = Convert.ToInt32(hidField.Value);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This post shows how to axiomatise a length function for Z3's built-in lists. However,
This link shows you that jQuery uses (new Function(return + data))(); for older browsers,
This function is supposed to hide the patient note and show the next note
This shows what I have and want: So yeah as you can see I
i have this query but this shows column does not exist SELECT p.content, (select
if i remove a.three display block this shows up fine. However what i want
This drawing shows a tree of parent-child relationships. It is directed, without cycles. A
This link shows how to inject JavaScript code to WebView object in Android. However
This question shows the usage of **var = new Object(); and that's something totally
This code shows syntax error in the parameter declaration.. Pls help me to solve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.