急! JavaScript 问题
我要实现按用户ID 用户姓名(假设英文) 用户生日排序,下面这些代码不知如何修改,后台代码往哪插,谢谢指点Javascript代码如下:
<script language="javascript">
function Getsort(obj)
{
document.all.sortfield.value=obj;
if (document.all.sortstring.value == 'ASC')
{
document.all.sortstring.value = 'DESC';
}
else if (document.all.sortstring.value == 'DESC')
{
document.all.sortstring.value = 'ASC';
}
__doPostBack('LinkButton1','');
}
</script>
HTML中:
<INPUT type="hidden" id="sortfield" runat="server">
<INPUT type="hidden" id="sortstring" runat="server" value="ASC">
<td ondblclick="Getsort('Text');"><b>双击此处可排序</b></td>
后台代码如下:
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
CreaterDataSource("Text ASC");
}
}
private void CreaterDataSource(string sort)
{
OleDbConnection dbCon = new OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("Test.mdb"));
dbCon.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM Table", dbCon);
DataTable dt = new DataTable();
adapter.Fill(dt);
DataView dv = dt.DefaultView;
dv.Sort = sort;
Repeater1.DataSource=dv;
Repeater1.DataBind();
}
private void LinkButton1_Click(object sender, System.EventArgs e)
{
string sortString = Request.Form["sortstring"].ToString();
string sortfield = Request.Form["sortfield"].ToString();
string fullsortstring = sortfield+" "+sortString;
if (fullsortstring != ""&& fullsortstring!=null)
{
CreaterDataSource(fullsortstring);
}
}