use session so that the username will be displayed in another webform asp c#
if (Context.Session != null) { BindGrid(); }else { Response.Redirect("Login.aspx"); }
private void BindGrid(string sortExpression = null) { conn.Open(); SqlCommand cmd = new SqlCommand("SELECT * from [test].[dbo].[myform] ", conn); SqlDataAdapter sda = new SqlDataAdapter(); cmd.Connection = conn; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); if (sortExpression != null) { DataView dv = dt.AsDataView(); this.SortDirection = this.SortDirection == "ASC" ? "DESC" : "ASC"; dv.Sort = sortExpression + " " + this.SortDirection; GridView2.DataSource = dv; } else { GridView2.DataSource = dt; } GridView2.DataBind(); conn.Close(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)