sorting - How to sort Culture Specific DataTime Column in a datatable(jquery) which has empty columns too -
i working on mvc , using datatable has column of type datetime. column has few blank( empty) cells too. achiving using string property fill column instead of datetime property. also, date should culture-specific
html code:
<tbody> @foreach (var item in model.xyz) { <tr> <td> @item.accountname </td> <td> @item.accountid </td> <td> @if (item.lastlogindate.equals(datetime.minvalue)) { <text>@item.slastlogindate</text> } else { //this customculture value : //cultureinfo customculture = new cultureinfo("some culture"); <text>@item.lastlogindate.tostring("dd/mm/yyyy hh:mm:ss", customculture)</text> } </td> </tr> } </tbody>
c# code model:
for(some iterations) { datarow row = dt.rows[i]; xyzentity objxyzentity = new xyzentity(); if (!row["saccounts"].equals(dbnull.value)) objxyzentity.accountname = convert.tostring(row["saccounts"]); if (!row["laccountid"].equals(dbnull.value)) objxyzentity.accountid = convert.tostring(row["laccountid"]); if (!row["dlastlogintime"].equals(dbnull.value)) objxyzentity.lastlogindate = convert.todatetime(row["dlastlogintime"]); objxyzentity.slastlogindate = string.empty; //using string property in case database cell empty lstxyzentity.add(objxyzentity); } return lstxyzentity;
i have taken string property "slastlogindate" , datetime property "lastlogindate". when cell in database empty, using "slastlogindate" instead of datetime property "lastlogindate". implementation, not able proprly sort datetime column.
Comments
Post a Comment