I populate a textbox with date from a datepicker with Calendar1.SelectedDate.ToShortDateString();,
after which I store in an Oracle database with a query shown below
string query3 = "insert into leave_module1 values(:srno,:name,:desig,:tol,:compdates,:fd,:td,:nod,:da,:ds,st.nextval)";
OracleCommand cmd = new OracleCommand(query3, con);
try
{
cmd.Parameters.Add(":srno", OracleType.Number, 8).Value = DropDownList2.Text;
cmd.Parameters.Add(":name", OracleType.VarChar, 50).Value = TextBox8.Text;
cmd.Parameters.Add(":desig", OracleType.VarChar, 30).Value = TextBox10.Text;
cmd.Parameters.Add(":tol", OracleType.VarChar, 10).Value = DropDownList1.Text;
cmd.Parameters.Add(":compdates", OracleType.VarChar, 30).Value = TextBox9.Text;
cmd.Parameters.Add(":fd", OracleType.DateTime).Value = TextBox3.Text;
cmd.Parameters.Add(":td", OracleType.DateTime).Value = TextBox4.Text;
cmd.Parameters.Add(":nod", OracleType.Number, 3).Value = TextBox5.Text;
cmd.Parameters.Add(":da", OracleType.DateTime).Value = TextBox11.Text;
cmd.Parameters.Add(":ds", OracleType.DateTime).Value = TextBox7.Text;
cmd.ExecuteNonQuery();
ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('The Data has been added');window.location='Default2.aspx';</script>;");
}
catch
{
Label13.Visible = true;
}
But when I populate a GridView in another page with the stored dates, I get a timestamp even though I did not input one. Please tell me how to remove the timestamp from the display!
Thanks in advance
This is how I populate the gridview
protected void Button3_Click(object sender, EventArgs e)
{
string v = System.Configuration.ConfigurationManager.ConnectionStrings["harish"].ConnectionString;
con = new OracleConnection(v);
con.Open();
cmd = new OracleCommand("select * from leave_module1 where srno='"+DropDownList1.Text+"'", con);
dr = cmd.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
con.Close();
dr.Close();
}
So you are querying all the columns from the database and then auto-generating the columns. This is why all the columns are displayed. To resolve this
rarely do you want to use auto-generated anything, as you loose call control to customize the behavior and output.