I want to view it in datagrid which the input will be added each time the user clicks the button..How would I make it to do that..Now it can be saved to database…But I want it to view in the interface itself in datagrid order which each time the user click on add data,it would save into database together it displays in the datagrid format in front-end..TQ
protected void Button2_Click(object sender, EventArgs e)
{
if (Session["Time"].ToString() == ViewState["Time"].ToString())
{
SqlConnection connection = new SqlConnection("Data Source=RGUNASEL- DESK\\SQLEXPRESS;Initial Catalog=eLogbook;User ID=sa;Password=1234");
connection.Open();
SqlCommand cmd = new SqlCommand("eform2", connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@lot_num", SqlDbType.VarChar, 50)).Value = TextBox8.Text;
cmd.Parameters.Add(new SqlParameter("@location", SqlDbType.VarChar, 50)).Value = TextBox9.Text;
cmd.Parameters.Add(new SqlParameter("@total_in", SqlDbType.VarChar)).Value = TextBox10.Text;
cmd.Parameters.Add(new SqlParameter("@first_test", SqlDbType.VarChar, 50)).Value = TextBox11.Text;
cmd.Parameters.Add(new SqlParameter("@second_test", SqlDbType.VarChar)).Value = TextBox12.Text;
cmd.Parameters.Add(new SqlParameter("@third_test", SqlDbType.VarChar, 50)).Value = TextBox13.Text;
cmd.Parameters.Add(new SqlParameter("@total_out", SqlDbType.VarChar, 50)).Value = TextBox14.Text;
cmd.Parameters.Add(new SqlParameter("@lot_status", SqlDbType.VarChar, 50)).Value = TextBox17.Text;
cmd.Parameters.Add(new SqlParameter("@remark", SqlDbType.VarChar, 50)).Value = TextBox16.Text;
cmd.ExecuteNonQuery();
Response.Write("Submitted!");
TextBox8.Text = null;
TextBox9.Text = null;
TextBox10.Text = null;
TextBox11.Text = null;
TextBox12.Text = null;
TextBox13.Text = null;
TextBox14.Text = null;
TextBox17.Text = null;
TextBox16.Text = null;
Session["Time"] = DateTime.Now.ToString();
}
else
{
// Code for page refresh....
TextBox8.Text = null;
TextBox9.Text = null;
TextBox10.Text = null;
TextBox11.Text = null;
TextBox12.Text = null;
TextBox13.Text = null;
TextBox14.Text = null;
TextBox17.Text = null;
TextBox16.Text = null;
Response.Write("Page Refreshed!");
}
}
Hey no need of checking time and all just Rebind the gridview after each data/row adding.
like
ie
EDIT: