hello ,
When i try search data from sql and get all data in textbox the DATE show full date and time
i want only date like 2021/01/23
my html :
<asp:TextBox ID="txtBoxDate8" runat="server" AutoPostBack="True" Font-Bold="True" Font-Names="Arial" Font-Size="X-Large" Style="text-align: center" ForeColor="Blue" BackColor="#FFFFCC" BorderColor="#FFFFCC"></asp:TextBox>
<asp:TextBox ID="txtBoxDate10" runat="server" AutoPostBack="True" Font-Bold="True" Font-Names="Arial" Font-Size="X-Large" ForeColor="Red" Style="text-align: center" BackColor="#FFFFCC" BorderColor="#FFFFCC"></asp:TextBox>
C#:
protected void Searchdata()
{
try
{
String constring = ConfigurationManager.ConnectionStrings["kankonConnectionString"].ConnectionString;
SqlConnection sqlcon = new SqlConnection(constring);
String pname = "Insert_Userupdate"; ;
sqlcon.Open();
SqlCommand com = new SqlCommand(pname, sqlcon);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("civilid", txtSearch.Text);
com.Parameters.AddWithValue("name", txtSearch.Text);
SqlDataReader rdr;
rdr = com.ExecuteReader();
if (rdr.Read())
{
txtUsername.Text = rdr["name"].ToString();
joptitel.Text = rdr["jop"].ToString();
markazel3mel.Text = rdr["markazel3mal"].ToString();
filenumber.Text = rdr["fileid"].ToString();
civilid.Text = rdr["civilid"].ToString();
eldarajah.Text = rdr["eldarajah"].ToString();
workdate.Text = rdr["workdate"].ToString();
txtBoxDate8.Text = rdr["DateTimePicker1"].ToString();
txtBoxDate10.Text = rdr["DateTimePicker2"].ToString();
string dtVal = workdate.Text.Trim();
DateTime Dob = Convert.ToDateTime(dtVal);
Label_day.Text = CalculateAge(Dob);
}
else
{
ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('" + "لاتوجد بيانات\\n " + txtSearch.Text.ToString() + "');", true);
}
sqlcon.Close();
}
catch (Exception)
{
}
}
SQL :
[DateTimePicker1] [date] NULL,
[DateTimePicker2] [date] NULL,
USE [kankon]
GO
/****** Object: StoredProcedure [dbo].[Insert_Userupdate] Script Date: 1/23/2021 2:47:42 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[Insert_Userupdate]
(
@name nvarchar(max),
@civilid nvarchar(max)
)
as
begin
Select * from Table_infoname where name LIKE '%' + @name +'%' OR civilid LIKE '%' + @civilid +'%'
end