How to convert a field in a LINQ query
-
One of the fields in my LINQ query is called 'DiaryDate'. This is a DateTime field. I want to convert it to a string in the format "dd/MM/yyyy" before I bind it to the grid (ugrdCases). How can I do this?
var query = from c in this.BL.Policy.Cases
select new
{
c.Value.CaseNumber,
c.Value.TypeDescription,
c.Value.AreaOfLawDescription,
c.Value.DiaryDate,
c.Value.ReportedDate,
c.Value.StatusDescription,
c.Value.LegalAdvisor.FirstName,
c.Value.LegalAdvisor.BranchDescription,
};
ugrdCases.DataSource = null;
ugrdCases.DataBind();
ugrdCases.DataSource = query;
ugrdCases.DataBind(); -
One of the fields in my LINQ query is called 'DiaryDate'. This is a DateTime field. I want to convert it to a string in the format "dd/MM/yyyy" before I bind it to the grid (ugrdCases). How can I do this?
var query = from c in this.BL.Policy.Cases
select new
{
c.Value.CaseNumber,
c.Value.TypeDescription,
c.Value.AreaOfLawDescription,
c.Value.DiaryDate,
c.Value.ReportedDate,
c.Value.StatusDescription,
c.Value.LegalAdvisor.FirstName,
c.Value.LegalAdvisor.BranchDescription,
};
ugrdCases.DataSource = null;
ugrdCases.DataBind();
ugrdCases.DataSource = query;
ugrdCases.DataBind();Hi, This should be done on your GridView control using the
DataFormatString
property. Regards,Syed Mehroz Alam My Blog | My Articles
Computers are incredibly fast, accurate, and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination. - Albert Einstein -
Hi, This should be done on your GridView control using the
DataFormatString
property. Regards,Syed Mehroz Alam My Blog | My Articles
Computers are incredibly fast, accurate, and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination. - Albert Einstein