Good day i created a table to be displayed on A adminlte template but it is not displaying the data from the database on the table
- namespace WebApplication4
- {
- public partial class transahis : System.Web.UI.Page
- {
- SqlDataAdapter da;
- DataSet ds = new DataSet();
- StringBuilder htmlTable = new StringBuilder();
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!Page.IsPostBack)
- {
- binddata();
- }
- }
- private void binddata()
- {
- SqlConnection con = new SqlConnection();
- ;
- con.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\odt\Documents\login.mdf;Integrated Security=True;Connect Timeout=30";
- //con.Open();
- // SqlCommand cmd = new SqlCommand();
- //cmd.CommandText = "select * from [log] ";
- SqlCommand cmd = new SqlCommand("SELECT * FROM log ", con);
- da = new SqlDataAdapter(cmd);
- da.Fill(ds);
- con.Open();
- cmd.ExecuteNonQuery();
- con.Close();
- //cmd.Connection = con;
- // SqlDataReader dt = cmd.ExecuteReader();
- htmlTable.Append("
");
");- htmlTable.Append("
");ID Name password - if (!object.Equals(ds.Tables[0], null))
- {
- if (ds.Tables[0].Rows.Count > 0)
- {
- for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
- {
- htmlTable.Append("
"); ");- htmlTable.Append("
" + ds.Tables[0].Rows[i]["Id"] + " ");- htmlTable.Append("
" + ds.Tables[0].Rows[i]["username"] + " ");- htmlTable.Append("
" + ds.Tables[0].Rows[i]["password"] + " ");- /* htmlTable.Append("
" + ds.Tables[0].Rows[i]["ContactNo"] + " ")*/- ;
- htmlTable.Append("
- }
- htmlTable.Append("
- htmlTable.Append("
- hph.Controls.Add(new Literal { Text = htmlTable.ToString() });
- }
- else
- {
- htmlTable.Append("
"); ");- htmlTable.Append("
There is no Record. ");- htmlTable.Append("
- htmlTable.Append("
- }
- }
- }
- }
- }
Rajanikant HawaldarPosted May 7, 2019, 1:24 AM