Hi akhter,
Check below code it's working.
HTML
Date :
<asp:TextBox runat="server" ID="txtDate" />
<br />
<asp:Button Text="Insert" runat="server" OnClick="Save" />
<br />
<asp:GridView runat="server" ID="gvDates" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="DateData" HeaderText="DateData" />
</Columns>
</asp:GridView>
Namespaces
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
Code
protected void Save(object sender, EventArgs e)
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("INSERT INTO InsertDate VALUES(@Date)", con);
cmd.Parameters.AddWithValue("@Date", txtDate.Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
cmd = new SqlCommand("SELECT DateData FROM InsertDate", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
gvDates.DataSource = dt;
gvDates.DataBind();
}
Screenshot
Database