排序是自己写的..不是DataGrid自带的那种..是用一个下拉列表外加一个Button做的..我想分页后还能排序怎么做??分页程序是用的AspNetPager..public static DataSet Bind_Order_By_Hit(string Class,int PageTotal,int PageSize)
{
string Sql = "Select * From VV_Video Where Video_Class='" + Class + "' Order By Video_Hit Desc";
DataSet DS=DB_Operate.Get_DS(Sql);
return DS;
} //按时间排序
public static DataSet Bind_Order_By_Time(string Class, int PageTotal, int PageSize)
{
string Sql = "Select * From VV_Video Where Video_Class='" + Class + "' Order By Video_Time Desc";
DataSet DS = DB_Operate.Get_DS(Sql);
return DS;
} //按大小排序
public static DataSet Bind_Order_By_Size(string Class, int PageTotal, int PageSize)
{
string Sql = "Select * From VV_Video Where Video_Class='" + Class + "' Order By Video_Size Desc";
DataSet DS = DB_Operate.Get_DS(Sql);
return DS;
}
string Video_Class=Request.QueryString["Video_Class"];
string Num = this.Px_DropDownList.SelectedValue.ToString();
switch (Num)
{
case "1":
Video_DataGrid.DataSource = Create_Bind.Bind_Order_By_Hit(Video_Class, Video_AspNetPager.PageSize * (Video_AspNetPager.CurrentPageIndex - 1), Video_AspNetPager.PageSize);
Video_DataGrid.DataBind();
break;
case "2":
Video_DataGrid.DataSource = Create_Bind.Bind_Order_By_Time(Video_Class, Video_AspNetPager.PageSize * (Video_AspNetPager.CurrentPageIndex - 1), Video_AspNetPager.PageSize);
Video_DataGrid.DataBind();
break;
case "3":
Video_DataGrid.DataSource = Create_Bind.Bind_Order_By_Size(Video_Class, Video_AspNetPager.PageSize * (Video_AspNetPager.CurrentPageIndex - 1), Video_AspNetPager.PageSize);
Video_DataGrid.DataBind();
break;
}
{
string Sql = "Select * From VV_Video Where Video_Class='" + Class + "' Order By Video_Hit Desc";
DataSet DS=DB_Operate.Get_DS(Sql);
return DS;
} //按时间排序
public static DataSet Bind_Order_By_Time(string Class, int PageTotal, int PageSize)
{
string Sql = "Select * From VV_Video Where Video_Class='" + Class + "' Order By Video_Time Desc";
DataSet DS = DB_Operate.Get_DS(Sql);
return DS;
} //按大小排序
public static DataSet Bind_Order_By_Size(string Class, int PageTotal, int PageSize)
{
string Sql = "Select * From VV_Video Where Video_Class='" + Class + "' Order By Video_Size Desc";
DataSet DS = DB_Operate.Get_DS(Sql);
return DS;
}
string Video_Class=Request.QueryString["Video_Class"];
string Num = this.Px_DropDownList.SelectedValue.ToString();
switch (Num)
{
case "1":
Video_DataGrid.DataSource = Create_Bind.Bind_Order_By_Hit(Video_Class, Video_AspNetPager.PageSize * (Video_AspNetPager.CurrentPageIndex - 1), Video_AspNetPager.PageSize);
Video_DataGrid.DataBind();
break;
case "2":
Video_DataGrid.DataSource = Create_Bind.Bind_Order_By_Time(Video_Class, Video_AspNetPager.PageSize * (Video_AspNetPager.CurrentPageIndex - 1), Video_AspNetPager.PageSize);
Video_DataGrid.DataBind();
break;
case "3":
Video_DataGrid.DataSource = Create_Bind.Bind_Order_By_Size(Video_Class, Video_AspNetPager.PageSize * (Video_AspNetPager.CurrentPageIndex - 1), Video_AspNetPager.PageSize);
Video_DataGrid.DataBind();
break;
}
解决方案 »
- 前台怎样获取两个datetime类型的值 相差的天数
- 为何 PostedFile.FileName 得不到客户端 详细路径(vb.net)
- ASP.NET 中Input Type=Text放入到Table中时右边被复盖的问题
- CSDN博客中插入c#代码存在一个BUG,望大家注意 |
- 表单内只能输入 数字 1-31 ,正式表达式怎么写?
- dataview中日期字段格式
- 请问这段代码是什么意思?
- 各位好!有没有谁能提供Treeview右键单击进行操作的源码?
- 關于GridVieW本地化的問題?
- 服务器升级为域控制器后asp.net出错,怎么办?
- 关于页面跳转回前一页面的问题,解决了立刻给分!
- 最近active 控件出现问题,是补丁影响还是动态链接库版本冲突
1.在頁面加一個htmlinputHidden;
2.用戶點擊某一名稱進行排序時,將這個名稱記錄下來,放在htmlinputHidden中;
3.看看你的數據庫中對應與這個名稱的是哪個字段,再按這個字段排序.例如:
sql="select * from yourtable order by " & getField(htmlinputHidden.value)
DataGrid1.datasource=sqlhelper.ExecuteDataset(strconnectionstring,CommandType.Text,sql)
DataGrid1.databindfunction getField(byval str as string) as stringdim ret as stringselect case
case "A"
ret="FieldA"
...
end selectend function
case "A"
ret="FieldA"
...
end select
end function-->
function getField(byval str as string) as stringdim ret as stringselect case
case "A"
ret="FieldA"
...
end select
return ret '返回排序字段
end function