C# code<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>后台程序页面 
C# codeprivate void titlelink()
    {
        
        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();    }这是一个朋友贴出的一段代码,具体什么意思差不多明白,想请各位帮忙找下错误,小弟不才,不能帮这位兄弟,还请大家帮忙!

解决方案 »

  1.   

    这句话有错误吗
    <a href="index.aspx?game= <%# Eval("game") %>" onclick="titlelink">
      

  2.   

    这句有错误 string title = Request["game"].ToString(); 
    string title =Request.QueryString["game"].ToString(); 
      

  3.   


    有錯誤。
    正確寫法:
    <a href=‘index.aspx?game= <%# Eval("game") %>’ onclick="titlelink">
      

  4.   

    <a href="index.aspx?game= <%# Eval("game") %>" onclick="titlelink">
    html链接能够调用c#方法吗? onclick="titlelink"C# codeprivate void titlelink() 
      

  5.   

    在当前页面没有跳转为什么能用request呢??
      

  6.   

    C# code <asp:TemplateField> 
            <ItemTemplate> 
            <table width="100" border="0" cellpadding="0" cellspacing="0"> 
            <tr> 
            <td> <a href='index.aspx?game= <%# Eval("game") %>' onclick="titlelink"> <%#Eval("game") %> </a> </td> 
            </tr> 
            </table> 
            </ItemTemplate> 
            <HeaderTemplate> 
              游戏名称 
              </HeaderTemplate> 
            </asp:TemplateField> 
    后台程序页面 
    C# codeprivate void titlelink() 
        { 
            
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString); 
            con.Open();         string title = "";
            if(Request.QueryString["game"]!=null)
            {
               title =Request.QueryString["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.Tables["order"]; 
            this.GridView1.DataBind(); 
            con.Close();     } 
      

  7.   

    if(Request.QueryString["game"]!=null) //判断地址栏是否有这个参数
    this.GridView1.DataSource = ds.Tables["order"]; //数据源是表(数据集ds中的表"order")
      

  8.   

    初步认定这里错误<a href="index.aspx?game= <%# Eval("game") %>" onclick="titlelink">