//below code will insert data into database contact table //qry is a type of string that is taking code of entering the data into the contact table protected void Button1_Click(object sender, EventArgs e) { DatabaseLayer.Connection obj = new DatabaseLayer.Connection(); String qry = "insert into Contact (Name,Email,Msg) values('" + TxtName.Text + "','" + TxtEmail.Text + "','" + TxtMsg.Text + "')"; obj.SqlQuery(qry); //this will make text box empty after entering data into the databse TxtName.Text = ""; TxtEmail.Text = ""; TxtMsg.Text = ""; }
protected void Page_Load(object sender, EventArgs e) { DatabaseLayer.Connection obj = new DatabaseLayer.Connection(); DataTable tbl = new DataTable(); tbl = obj.srchRecord("select BookName,AuthorName,Price from Purchase"); String dt = ""; if (tbl.Rows.Count > 0) { for (int x = 0; x < tbl.Rows.Count; x++) { dt = dt + "<div class='col-md-4' style='background-color:black;'><center><h2 style='text-align:center;color:white;'>" + tbl.Rows[x]["BookName"] + "</h2><img src='images/bg1.jpg' class='img img-thumbnail'><br/><h3 style='color:white;'> $" + tbl.Rows[x]["Price"] + "</h3><center></div>"; } data.InnerHtml = dt; } }