Textbox TextMode is Date

2019-08-23 07:24发布

i try retrive data from db-(sql-server) but im can't fill textbox becusee

TextMode = "Date"

my field in db is DateTime

string transDate = dr["TransDate"].ToString();
txtTransDate.Text = string.Format("{0:dd/MM/yyyy}", dr["TransDate"].ToString());


 <asp:TextBox ID="txtTransDate" runat="server" TextMode="Date"
                                            CssClass="form-control"></asp:TextBox>

1条回答
不美不萌又怎样
2楼-- · 2019-08-23 08:15

you can try below code

var date=DateTime.Parse(dr["TransDate"].ToString());
txtTransDate.Text=date.ToString("dd.MM.yyyy);
查看更多
登录 后发表回答