这是一段排序的代码,根据点击的值来重新排序。 我发现一个非常奇怪的问题。 我数据库里的game列 有各种游戏。魔兽世界,实况足球什么的。
点这些字段后都可以正常排到前面。但是 就是劲舞团不行,不知道为什么。我把劲舞团改成劲舞都能正常排序。这事可真新鲜了,一点劲舞团,就什么反应都没有protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Request.QueryString["game"]))
{
BindGrid(Request.QueryString["game"]);
}
else
{
BindGrid(string.Empty);
}
}
private void BindGrid(string game)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString); string cmd = string.Empty;
if (string.IsNullOrEmpty(game))
{
cmd = "select game,sn from [order]";
}
else
{
cmd = "select game,sn from [order] where game= '" + game + "'union all select game,sn from [order] where game <> '" + game + "' ";
}
SqlDataAdapter sda = new SqlDataAdapter(cmd, con);
DataSet ds = new DataSet(); con.Open();
sda.Fill(ds);
con.Close(); System.Text.StringBuilder str = new System.Text.StringBuilder();
str.Append("<table border = 1>");
str.Append("<tr>");
for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
{
str.Append("<td>" + ds.Tables[0].Columns[i].ColumnName + "</td>");
}
str.Append("</tr>");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
str.Append("<tr>");
for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
{
str.Append("<td><a href=index.aspx?game=" + ds.Tables[0].Rows[i][j].ToString() + ">" + ds.Tables[0].Rows[i][j].ToString() + "</a></td>");
}
str.Append("</tr>");
} Response.Write(str.ToString());
}
点这些字段后都可以正常排到前面。但是 就是劲舞团不行,不知道为什么。我把劲舞团改成劲舞都能正常排序。这事可真新鲜了,一点劲舞团,就什么反应都没有protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Request.QueryString["game"]))
{
BindGrid(Request.QueryString["game"]);
}
else
{
BindGrid(string.Empty);
}
}
private void BindGrid(string game)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString); string cmd = string.Empty;
if (string.IsNullOrEmpty(game))
{
cmd = "select game,sn from [order]";
}
else
{
cmd = "select game,sn from [order] where game= '" + game + "'union all select game,sn from [order] where game <> '" + game + "' ";
}
SqlDataAdapter sda = new SqlDataAdapter(cmd, con);
DataSet ds = new DataSet(); con.Open();
sda.Fill(ds);
con.Close(); System.Text.StringBuilder str = new System.Text.StringBuilder();
str.Append("<table border = 1>");
str.Append("<tr>");
for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
{
str.Append("<td>" + ds.Tables[0].Columns[i].ColumnName + "</td>");
}
str.Append("</tr>");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
str.Append("<tr>");
for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
{
str.Append("<td><a href=index.aspx?game=" + ds.Tables[0].Rows[i][j].ToString() + ">" + ds.Tables[0].Rows[i][j].ToString() + "</a></td>");
}
str.Append("</tr>");
} Response.Write(str.ToString());
}
解决方案 »
- 怎么在一个Datalist中获取另一个页面的Datalist的控件值啊!!急啊
- 将DataGrid绑定的数据数据写入数据库
- WebForm间传值问题
- asp.net 中我用了 cdo 发送电子邮件,我把 cdosys.dll 这个文件放在 bin 中,然后引用此dll 进行发信.......详情请进!!
- 发邮件出错了??? "未能访问“CDO.Message”对象。"
- 有谁遇到这个问题?帮我看看,怎么解决?
- .net 2005 的GridView 的模板列中,如何取得当前行?
- 实现复杂的报表
- 怎样得到<iframe>中Page当前的URL,我用src只得到最初设置的src
- 关于datetimepicker控件的问题?
- SQL Server2005数据删了一条数据,可不可以恢复啊?
- 一个比较难的SQL语句???
..................oh my god
我用的是本地的sql server”是简体中文版