我在game字段那里写了个link方法, 通过点击获得game字段值值。然后后台程序根据所得值在排序gridview ,但是运行以后点击没有任何反应 ,不知道哪里错了 前台页面
<asp:TemplateField>
<ItemTemplate>
<table width="100" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><a href="index.aspx?game=<%# Eval("game") %>" onclick="titlelink"><%# DataBinder.Eval(Container.DataItem,"game") %></a></td>
</tr>
</table>
</ItemTemplate>
<HeaderTemplate>
游戏名称
</HeaderTemplate>
</asp:TemplateField>后台程序页面
private void link()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
con.Open(); string title = Request["game"].ToString(); //获取前台点击game字段的值 ,然后放到下面的select里面。
string cmdtext = "select * from [order] where game = '" + title + "'"; SqlCommand cmd = new SqlCommand(cmdtext, con);
SqlDataAdapter sda = new SqlDataAdapter(cmdtext, con);
DataSet ds = new DataSet();
sda.Fill(ds, "[order]");
this.GridView1.DataSource = ds;
this.GridView1.DataBind();
con.Close(); }现在问题就是 前台gridview中的:<a href="index.aspx?game=<%# Eval("game") %>" onclick="titlelink"><%# DataBinder.Eval(Container.DataItem,"game") %></a>
还有后台的string title = Request["game"].ToString();
这两句无法连同。不知道是我方法写错了。还是什么其他问题
<asp:TemplateField>
<ItemTemplate>
<table width="100" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><a href="index.aspx?game=<%# Eval("game") %>" onclick="titlelink"><%# DataBinder.Eval(Container.DataItem,"game") %></a></td>
</tr>
</table>
</ItemTemplate>
<HeaderTemplate>
游戏名称
</HeaderTemplate>
</asp:TemplateField>后台程序页面
private void link()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
con.Open(); string title = Request["game"].ToString(); //获取前台点击game字段的值 ,然后放到下面的select里面。
string cmdtext = "select * from [order] where game = '" + title + "'"; SqlCommand cmd = new SqlCommand(cmdtext, con);
SqlDataAdapter sda = new SqlDataAdapter(cmdtext, con);
DataSet ds = new DataSet();
sda.Fill(ds, "[order]");
this.GridView1.DataSource = ds;
this.GridView1.DataBind();
con.Close(); }现在问题就是 前台gridview中的:<a href="index.aspx?game=<%# Eval("game") %>" onclick="titlelink"><%# DataBinder.Eval(Container.DataItem,"game") %></a>
还有后台的string title = Request["game"].ToString();
这两句无法连同。不知道是我方法写错了。还是什么其他问题
你前台生成页面的时候,"game="的后面有没有读到值?
如果有显示,那么就到index.aspx页面时写
Response.Write(Request.QueryString["game"].ToString());
Response.End();
看能不能显示要读的game值.
如果能读到,那就可以把值给title变量了。