欄位排序
提供你解方,我是套在dl上面的,你可以自行改寫。
protected void GvSort(object sender, EventArgs e)
{
GridView gv = pre_gv;
DropDownList dl = (DropDownList)sender;
string exp = "";
SortDirection dir = SortDirection.Ascending; ;
if (dl.SelectedIndex == 0) return;
switch ( dl.SelectedIndex)
{
case 1:
exp = "prd_s";
break;
case 2:
exp = "prd_s";
dir = SortDirection.Descending;
break;
case 3:
exp = "sup_s";
break;
case 4:
exp = "sup_s";
dir = SortDirection.Descending;
break;
case 5:
exp = "cus_s";
break;
case 6:
exp = "cus_s";
dir = SortDirection.Descending;
break;
case 7:
exp = "p_q";
break;
default :
break;
}
gv.Sort(exp, dir);
}