[英]Get Value of Cell Row in DataGridView
I'm trying to get the value of a two columns
, If one column is blank
it still returns a value for example if the column1
is blank
and column2
is not it will still return a value. 我正在尝试获取两
columns
的值,如果某一列为blank
则它仍会返回一个值,例如,如果column1
为blank
而column2
不是,则它仍将返回一个值。 My Code: 我的代码:
DateTime rowtype = Convert.ToDateTime(row.Cells["CreatedOn"].Value);
string status= row.Cells["Status"].Value.ToString();
if (rowtype < DateTime.Now.AddDays(-7) && status == "Open")
{
row.HeaderCell.Value = ">7";
}
How can i change the HeaderCell, only if the two columns contain the correct values? 仅当两列包含正确的值时,才能更改HeaderCell?
Based on your comment: 根据您的评论:
DateTime rowtype = Convert.ToDateTime(row.Cells["CreatedOn"].Value);
string status= row.Cells["Status"].Value.ToString();
DateTime dt = new DateTime(rowtype.Year, rowtype.Month, rowtype.Day);
DateTime today = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
if (dt == today.AddDays(-7) && status == "Open")
{
row.HeaderCell.Value = ">7";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.