简体   繁体   English

如何从 SQL 服务器检索 DATE 值到 TEXTBOX 以进行数据更新

[英]How to retrieve DATE value from SQL Server to TEXTBOX for data UPDATE

i am using this code for retrieving value from sql column to textbox.我正在使用此代码从 sql 列检索值到文本框。 and i am using textmode="date" at input time to save DATE in database.And using a gridview link i want to redirect the row data to another page for edit and update.But the DATE value is not coming to TEXTBOX.我在输入时使用 textmode="date" 将 DATE 保存在数据库中。并使用 gridview 链接我想将行数据重定向到另一个页面进行编辑和更新。但是 DATE 值不会出现在 TEXTBOX 中。

Date_of_st.Text = ds.Tables[0].Rows[0][5].ToString();

Also tried these snippets:还尝试了这些片段:

 1 Convert.ToDateTime(dt.Rows[0]["Employee_DOB"]).ToString("dd-MM-yyyy");
 2 ((DateTime)ds.Tables[0].Rows[0]["Coat_CUSTM_Date"]).ToString("yyyy-MM-dd");
 3 suDateTime = DateTime.ParseExact(conv, "MM-dd-yyyy", null);

Suppose the row and col are correct, try this:假设 row 和 col 是正确的,试试这个:

  var date = ds.Tables[0].Rows[0][5].ToString();
  var dateRif = new DateTime();
  if (DateTime.TryParse(date, out dateRif))
  {
      //Do what you want
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM