问题描述
txtmembdate.Text = row.Cells [bdate]。Value.ToString();
这是我从datagridview到textbox获取日期的代码。
但事情是我只是在数据库中存储日期。但是当我从gridview从上面的代码中取出文本框时,我也得到时间..作为12/29/1990 12:00 PM所以我只想避免时间。
虽然我更新我的整个申请被绞死..
帮助我PLZ .. :(
从下面的评论中复制的其他信息
txtmembdate.Text = row.Cells["bdate"].Value.ToString();
this is my code to get date from datagridview to textbox.
but the thing is i just store date in database. but when i fetch from gridview to the text box from above code i get time also.. as 12/29/1990 12:00PM so i just want to avoid the time.
and while i update my whole application gets hanged..
help me plz.. :(
additional information copied from comment below
private void txtmembdate_Validating(object sender, CancelEventArgs e)
{
DateTime dob;
// DOB is required and must be a valid date
if (!DateTime.TryParse(txtmembdate.Text, out dob))
{
errorProviderbdate.SetError(txtmembdate, "Must be a date/time value");
e.Cancel = true;
return;
}
// Must be 18 or older
if (dob > DateTime.Now.AddYears(-18))
{
errorProviderbdate.SetError(txtmembdate, "Must be 18 or older");
e.Cancel = true;
return;
}
// DOB is valid
errorProviderbdate.SetError(txtmembdate, "");
}
dis是我要验证的代码..我只能在datagridview中看到日期但是,在获取...时间..也会出现
dis is my code to validate.. i can only see date in datagridview but, while fetching... time.. also appears
推荐答案
这篇关于如何仅从数据网格视图到文本框获取日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!