protected void Page_Load(object sender, EventArgs e) { //SqlConnection con = new SqlConnection("Data Source=asktoakhi.database.windows.net;Initial Catalog=asktoakhi;UID=asktoakhi;pwd=@K#!le47;Max Pool Size=100000;"); SqlConnection con = new SqlConnection("Data Source=.;database=jaspreet;integrated security=SSPI;"); SqlCommand cmd; SqlDataAdapter da = new SqlDataAdapter(); DataTable dt = new DataTable(); try { con.Open(); string Query = "SELECT * FROM jaspreet"; cmd = new SqlCommand(Query, con); da.SelectCommand = cmd; da.Fill(dt); if (dt.Rows.Count > 0) { GridAllUser.DataSource = dt; GridAllUser.DataBind(); } else { Response.Write("<Script>alert('No Record Found.');</Script>"); } } catch (Exception ex) { Response.Write("<Script>alert('" + ex.Message.ToString() + "');</Script>"); } finally { con.Close(); } }
private void SetAllUser() { List <User> user = ViewUserController.GetAllUserController(); GridAllUser.DataSource = user; GridAllUser.DataBind(); }