I am binding the dropdown values using LINQ as below
var varResult =
(from OppData in dtOpp.AsEnumerable()
select new
{
TEXT = OppData.Field<object>(sColName), //column value
VALUE = sColName // column Name
}
).Distinct();
Then the code is converted to datatable using LINQtoDataTable Function.
dtTemp = LINQToDataTable(varResult);
Then the dropdown is binded as seen below;
ddlTemp.DataSource = dtTemp;
ddlTemp.DataTextField = "TEXT";
ddlTemp.DataValueField = "VALUE";
ddlTemp.DataBind();
Now the value that dropdown binds for one of the column, (Employee Joining date) is in format of 08/09/2011~Y, because it is directly getting bind from database. I wish to apply substring on the date so that it is in format of 08/09/2011. How to apply substring on the LINQ queries?
Use your
TEXTfield in your anonymous type in LINQ query asstringand format value during query:Somethign like this. Also you can provide more meaningful format of date representation, ex: Aug 09, 2011, etc.