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

  • Home
  • SEARCH
  • 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 8507669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:56:08+00:00 2026-06-11T02:56:08+00:00

Windows: 7 Home Premium Visual Studio: 2012 Language: C# SQL: Server 2008 I am

  • 0

Windows: 7 Home Premium
Visual Studio: 2012
Language: C#
SQL: Server 2008

I am binding some labels and an Image to a DataReader, which is reading from a local DataBase.
The header label, and the Image URL of the image are binding properly, but the rest of the labels only get populated after I refresh the page.

The first image shows the page after I clicked on the user profile link. Notice that the 3 labels in the page have incorrect information:
Wrong Information

After a full page refresh, the data is displayed properly:
Incorrect Information

The code goes as follows

private static string _acceptingChallenges = "0";
private static string _curUser;
private static string _website = "[None]";
private static string _dateJoined = DateTime.Now.ToString();

protected void Page_Load(object sender, EventArgs e)
{
    if (!string.IsNullOrEmpty(Request.QueryString["user"]))
    {
        _curUser = (Request.QueryString["user"]);
        pnlProfilePublic.Visible = true;
        pnlProfilePrivate.Visible = false;
        PopulatePublic();
    }
    else
    {
        if (!string.IsNullOrEmpty((string) Session["Nickname"]))
        {
            _curUser = Session["Nickname"].ToString();
            pnlProfilePublic.Visible = false;
            pnlProfilePrivate.Visible = true;
            PopulatePrivate();
        }
        else
        {
            Response.Redirect("~/Default.aspx");
        }
    }

    InitiateData();
}

private void InitiateData()
{
    if (Master == null) return;

    Label lblTitle = (Label)Master.FindControl("lblTitle");

    const string strSql = "SELECT * FROM vwGetProfileDetails WHERE memberNickname=@member";

    var sqlComm = new SqlCommand(strSql, DataConn.Connect()) { CommandType = CommandType.Text };

    sqlComm.Parameters.Add(new SqlParameter("@member", SqlDbType.VarChar, 20)).Value = _curUser;

    var rdr = sqlComm.ExecuteReader();
    int count = 0;
    while (rdr.Read())
    {
        imgProfile.ImageUrl = rdr["memberAvatarLocation"].ToString();
        lblTitle.Text = _curUser + "'s Profile Page";

        _acceptingChallenges = rdr["memberAcceptingChallenge"].ToString();
        _website = rdr["memberWebsite"].ToString();
        _dateJoined = rdr["dateAdded"].ToString();

        count = count + 1;
    }

    rdr.Close();
    DataConn.Disconnect();
    Response.Write(count);
}
  • 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-11T02:56:10+00:00Added an answer on June 11, 2026 at 2:56 am

    PopulatePublic and PopulatePrivate are called before InitiateData… So they will be stored in the static strings and only populated next time the page is called.

    If you are using ASP.Net controls then auto view state will probably be enabled so on postback the controls will be repopulated. So you can do lblWebsite.Text = rdr[“memberWebsite”].ToString(); and let ASP.NET manage viewstate.. no need for static strings..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I install SQL Server 2008 Installation on Windows 7 Home Premium, with installing
We have a single computer with Windows7 Home Premium running with SQL Server 2008
Does Windows® 7 Home Premium 64-bit supports all versions of Visual Studio 2010? http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express
Having a strange issue with Visual Studio 2010 Professional (running Windows Vista Home Premium
I have a Dell Studio 540, 64 bit OS Windows Home Premium. My CPU
Is the Windows 7 Home Premium sufficient for software development? Development would be in
O/S: Windows 7 ,Home Premium I have just installed IIS manager Express from Web
I'm on Windows Vista Home Premium 64 bit OS. I use Apache Friends XAMPP
I am trying to run MySql 5.1 on Windows 7 Home Premium 64 bit.
I have developed a application for a client who uses windows 7 home premium

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.