title: Display DataTable information in aspx page
body: <p>I am new to Asp.net. I have created a login page which retrieves the user information in a DataTable. I am storing this information in a Session Variable.</p>
  
  <p>Here s the code:</p>
  
  <pre><code> using System;
  using System.Data;
  using System.Data.SqlClient;
  using System.Configuration;
  using System.Linq;
  using System.Web;
  using System.Web.Security;
  using System.Web.UI;
  using System.Web.UI.HtmlControls;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;
  using System.Xml.Linq;
  using System.Data;
  using System.Web.Configuration; 
  
  
  public partial class _Default : System.Web.UI.Page
  {
  protected void Page_Load(object sender, EventArgs e)
  {
  
  }
  protected void btnSubmit_Click(object sender, EventArgs e)
  {
      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString);
      con.Open();
      SqlCommand cmd = new SqlCommand("select * from UserTable where UserName =@username and Password=@password", con);
      cmd.Parameters.AddWithValue("@username", txtUserName.Text);
      cmd.Parameters.AddWithValue("@password", txtPWD.Text);
      SqlDataAdapter da = new SqlDataAdapter(cmd);
      DataTable dt = new DataTable();
      da.Fill(dt);
      if (dt.Rows.Count &gt; 0)
      {
          Session["userdata"] = dt;
          Response.Redirect("Home.aspx");
      }
      else
      {
          ClientScript.RegisterStartupScript(Page.GetType(), "validation", "&lt;script language='javascript'&gt;alert('Invalid Username and Password')&lt;/script&gt;");
      }
  }
  }
  </code></pre>
  
  <p>Now  want to display the DataTable information in Home.aspx. How can i do this?</p>