I have several columns which I've sorted but the Date Field sorts as a string
rather than as a date and I can't seem to figure out how to fix that.
Below is my code.
Thanks for your help.
public partial class MyProjects : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
if (!Page.IsPostBa ck)
{
Session["SortExpression "] = "";
Session["SortDirect ion"] = "";
}
SDU.Service_Cla ss.DataService ds =
new SDU.Service_Cla ss.DataService( Request.Applica tionPath,
"ProMan", SDU.Service_Cla ss.DataService. QueryType.STORE D_PROC,
"p_get_projects ");
if (ds.ExecuteComm and(30))
{
Session["MyProjects "] = ds.GetData.Tabl es[0];
gProjects.DataS ource = (DataTable)Sess ion["MyProjects "];
gProjects.DataB ind();
foreach (GridViewRow row in gProjects.Rows)
{
//row.Cells.
}
}
gProjects.RowSt yle.Height = 20;
{
String expression = "";
SortDirection direction;
}
}
protected void gProjects_Sorti ng(object sender,
GridViewSortEve ntArgs e)
{
DataView dv = new DataView((DataT able)Session["MyProjects "]);
string direction;
if (Session["SortExpression "].ToString() == e.SortExpressio n)
{
if (Session["SortDirect ion"].ToString() == "ASC")
{
direction = "DESC";
}
else
{
direction = "ASC";
}
}
else
{
direction = "ASC";
}
dv.Sort = e.SortExpressio n + " " + direction;
gProjects.DataS ource = dv;
gProjects.DataB ind();
Session["SortExpression "] = e.SortExpressio n;
Session["SortDirect ion"] = direction;
}
rather than as a date and I can't seem to figure out how to fix that.
Below is my code.
Thanks for your help.
public partial class MyProjects : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
if (!Page.IsPostBa ck)
{
Session["SortExpression "] = "";
Session["SortDirect ion"] = "";
}
SDU.Service_Cla ss.DataService ds =
new SDU.Service_Cla ss.DataService( Request.Applica tionPath,
"ProMan", SDU.Service_Cla ss.DataService. QueryType.STORE D_PROC,
"p_get_projects ");
if (ds.ExecuteComm and(30))
{
Session["MyProjects "] = ds.GetData.Tabl es[0];
gProjects.DataS ource = (DataTable)Sess ion["MyProjects "];
gProjects.DataB ind();
foreach (GridViewRow row in gProjects.Rows)
{
//row.Cells.
}
}
gProjects.RowSt yle.Height = 20;
{
String expression = "";
SortDirection direction;
}
}
protected void gProjects_Sorti ng(object sender,
GridViewSortEve ntArgs e)
{
DataView dv = new DataView((DataT able)Session["MyProjects "]);
string direction;
if (Session["SortExpression "].ToString() == e.SortExpressio n)
{
if (Session["SortDirect ion"].ToString() == "ASC")
{
direction = "DESC";
}
else
{
direction = "ASC";
}
}
else
{
direction = "ASC";
}
dv.Sort = e.SortExpressio n + " " + direction;
gProjects.DataS ource = dv;
gProjects.DataB ind();
Session["SortExpression "] = e.SortExpressio n;
Session["SortDirect ion"] = direction;
}
Comment