int worth=player_list.DataKeys[Convert.ToInt32(e.Item.Cells[8].Text)];int n = DataSet1.Tables["name"].Rows.Count;

解决方案 »

  1.   

    谢了 不过第二个问题是这样的
    查询一个表里面该用户的拥有的球员个数
    我知道好象用(count)
    那查询后怎么把结果拿出来付给n啊
      

  2.   

    sql:select count(*) from Tab
    执行后获得一个dataset,int n=Convert.ToInt32(DataSet1.Tables[0].Rows[0][0]);
      

  3.   

    用rs.recordcount来得到纪录个数
      

  4.   

    楼上的,你说的是ADO,现在是ADO.NET了!
      

  5.   

    这样可以吗?
    String SQL="Select count(*) from soccer_exchange where user_id=@user_id and state=1";
    DataSet ds=new DataSet();
    SqlDataAdapter Adapter=new SqlDataAdapter(SQL,Conn);
    Adapter.Fill(ds,"count");
    int n = ds.Tables["count"].Rows.Count;
      

  6.   

    不好意思发错了
    String SQL="Select count(*) from soccer_exchange where user_id=@user_id and state=1";
    cmd.Parameters.Add(new SqlParameter("@user_id",SqlDbType.Int,4));
    cmd.Parameters["@user_id"].Value =user_id;
    DataSet ds=new DataSet();
    SqlDataAdapter Adapter=new SqlDataAdapter(SQL,Conn);
    Adapter.Fill(ds,"count");
    int n =Convert.ToInt32(ds.Tables[0].Rows[0][0]);
    这样效率高吗?
      

  7.   

    执行一下,正确就行了,这么一条sql用不着谈效率,带参数的sql虽然用起来烦,但比起不带参数的sql有很多优点的!
      

  8.   

    问题1:<asp:TemplateColumn HeaderText="身价">
    <ItemTemplate>
    <%# (int)DataBinder.Eval(Container.DataItem,"worth")>10000?DataBinder.Eval(Container.DataItem,"worth")+"<FONT color=\"black\" size=\"3\">万</FONT>":DataBinder.Eval(Container.DataItem,"worth")%>

    </ItemTemplate>
    </asp:TemplateColumn>问题2:
    String SQL="Select count(*) from soccer_exchange where user_id=@user_id and state=1";SqlCommand cmd = new SqlCommand(SQL, Conn);
    conn.Open();
    int n = Int32.Parese(cmd.ExecuteScalar());conn.Close();
      

  9.   

    关于第一个问题,为什么不把[万]字放在页眉上!
    第二个问题
    如果你单单要获取个数,同时不查询数据的话
    String SQL="Select count(id) from soccer_exchange where user_id=@user_id and state=1";SqlCommand cmd = new SqlCommand(SQL, Conn);
    conn.Open();
    int n = Int32.Parese(cmd.ExecuteScalar());conn.Close();
    否则就用你自己的方法
      

  10.   

    执行说int并不包含对parese的定义