<asp:Repeater ID="rptname" runat="server">
    <ItemTemplate>
内容
     </ItemTemplate>
</asp:Repeater>

解决方案 »

  1.   

    protected void DataBind(int num,string rptname) 
    传得参数是string类型的
    比如时string rptname="ZZZZ"
    你不能"ZZZZ".DataSource = ds.Tables[0].DefaultView; 
         "ZZZZ".rptname.DataBind(); 
    还有,你传入的参数num在sql里边也不能这样写string str="select top num * from student"; 
    写成 string str="select top " + num + " * from student"; 
      

  2.   

    错误很明显,rptname 参数不可能是string类型 lz是想传个repeater控件名进来吧,把reptname前的参数类型改成
    如下:protected void DataBind(int num,System.Web.UI.WebControls.Repeater rptname) 但是看来Repeater本身就是页面中的,不知lz为何再找个参数传进来是何意??还有就是lz的SQL语句也有错呀要把 string str="select top num * from student"; 改写成string str="select top " + num + " * from student";  才可以呀
      

  3.   

        protected void DataBind(int num,Repeater rptname) 
        { 
            SqlConnection con = new SqlConnection(@"Data Source=bbe1e6eeea28453\sqlexpress;Initial Catalog=web10;Integrated Security=True;Pooling=False"); 
            string str="select top num * from student"; 
            con.Open(); 
            SqlDataAdapter da = new SqlDataAdapter(str,con); 
            DataSet ds = new DataSet(); 
            da.Fill(ds); 
            rptname.DataSource = ds.Tables[0].DefaultView; 
            rptname.DataBind(); 
        } 
      

  4.   

    查询命令语句都错了
    string str="select top " + num + " * from student";