Click here to Skip to main content
15,066,499 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a gridview where i have to load the current book details of a user. The userid is passed as a session and based on that session the grid view is displayed

C#
protected void Page_Load(object sender, EventArgs e)
    {
      
      
        if (Session["userid"] != null)
        {
            string key = Session["userid"].ToString();
            SqlDataSource1.SelectCommand = "SELECT fname,lastname,number,userid from users where userid= '" + key + "'";
            YourGridView.DataSource= SqlDataSource1;
            YourGridView.DataBind();
        }

    }


But the girdview just shows blank .I have checked whether the session is blank or not .It isin't. Why is the gridview blank?
Posted

1 solution

Hi ,
Check this
C#
protected void Page_Load(object sender, EventArgs e)
    {


        if (Session["userid"] != null)
        {
            string key = Session["userid"].ToString();
            SqlDataSource1.ConnectionString = "your conection";
            SqlDataSource1.SelectCommand = "SELECT fname,lastname,number,userid from users where userid= '" + key + "'";
            YourGridView.DataSource= SqlDataSource1;
            YourGridView.DataBind();
        }

    }

Best Regards
M.Mitwalli
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900