aspx_professional thread: Toggling datagrid sort order between ascending/descending
Much clearer.
Thank you!
Stephanie
-----Original Message-----
From: Michal Tesar [mailto:kariba@p...]
Sent: Friday, March 14, 2003 1:22 PM
To: ASPX_Professional
Subject: [aspx_professional] RE: Toggling datagrid sort order between
ascending/descending
hdnOrderBy, hdnASC_DESC are a hidden asp:TextBoxes
hdnOrderBy strores the orderby string and hdnASC_DESC stores either ASC
or
DESC
Now in PageLoad event I do this:
if(hdnOrderBy.Text =3D=3D ""){
hdnOrderBy.Text =3D "Left(Number, 1)";
hdnASC_DESC.Text =3D "ASC";
}
This is the default, when user accesses page fro the first time.
In datagrid I have:
<asp:TemplateColumn SortExpression=3D"DATEPART(year,Date)"
HeaderStyle-BackColor=3D"#D99800" HeaderText=3D"Date">
public void SortData(Object source, DataGridSortCommandEventArgs e){
//this current order of the datagrid, and assigns the opposite value
if(hdnASC_DESC.Text =3D=3D "ASC"){
hdnASC_DESC.Text =3D "DESC";
}
else{
hdnASC_DESC.Text =3D "ASC";
}
hdnOrderBy.Text =3D e.SortExpression.ToString();
//now you pass OrderBy string
BindData(hdnOrderBy.Text, hdnASC_DESC.Tex);
}
}
and in BindData() you just pass those two with other values to stored
procedure, and there put it in Order By statement.
Is this clearer?
Mike
-----Puvodn=ED zpr=E1va-----
Od: Patterson, Stephanie L [mailto:stephanie.l.patterson@i...]
Odesl=E1no: Friday, March 14, 2003 2:16 PM
Komu: ASPX_Professional
Predmet: [aspx_professional] RE: Toggling datagrid sort order between
ascending/descending
I must be missing something, I don't understand a few points.
What is "hdnASC_DESC" and "hdnOrderBy" and how does "hdnASC_DESC" set
the
sort order?
Thanks for your help!
Stephanie
-----Original Message-----
From: Michal Tesar [mailto:kariba@p...]
Sent: Friday, March 14, 2003 11:56 AM
To: ASPX_Professional
Subject: [aspx_professional] RE: Toggling datagrid sort order between
ascending/descending
I do it like this:
public void SortData(Object source, DataGridSortCommandEventArgs e){
if(hdnASC_DESC.Text =3D=3D "ASC"){
hdnASC_DESC.Text =3D "DESC";
}
else{
hdnASC_DESC.Text =3D "ASC";
}
hdnOrderBy.Text =3D e.SortExpression.ToString();
BindData();
}
}
Means that first you click on header, sorts ASC, the second tim you
click,
sorts Desc.
Mike
-----Puvodn=ED zpr=E1va-----
Od: Patterson, Stephanie L [mailto:stephanie.l.patterson@i...]
Odesl=E1no: Friday, March 14, 2003 12:51 PM
Komu: ASPX_Professional
Predmet: [aspx_professional] Toggling datagrid sort order between
ascending/descending
I have a datagrid that has AllowSorting=3D"True". It only sorts in
ascending
order. How can I get it to toggle from ascending/descending by
clicking on
the column header?
Thanks in advance!
Stephanie