日期:2014-05-19  浏览次数:20394 次

与“System.Web.UI.WebControls.TableRowCollection.Add(System.Web.UI.WebControls.TableRow)”最匹配的重载方法具有一些无效参数
编译错误    
说明:   在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。    

编译器错误信息:   CS1502:   与“System.Web.UI.WebControls.TableRowCollection.Add(System.Web.UI.WebControls.TableRow)”最匹配的重载方法具有一些无效参数  

源错误:  

   

行   33:                                   r.Cells.Add(c);  
行   34:                           }  
行   35:                           Table1.Rows.Add(r);  
行   36:                   }  
行   37:           }  
   

源文件:   e:\ASP.NET\Samples\HtmlTable.aspx.cs         行:   35    

这个错误怎么解决?  
这是一个动态创建表格的程序,各位帮我看看哈,页面上有一个Table1

        protected   void   Page_Load(object   sender,   EventArgs   e)
        {
                int   row   =   0;
                int   numrows   =   Int32.Parse(Select1.Value);
                int   numcells   =   Int32.Parse(Select2.Value);

                for   (int   j   =   0;   j   <   numrows;   j++)
                {
                        HtmlTableRow   r   =   new   HtmlTableRow();
                        //设定背景颜色
                        if   (row   %   2   ==   1)
                        {
                                r.BgColor   =   "Gainsboro ";
                        }
                        row++;
                        for   (int   i   =   0;   i   <   numcells;   i++)
                        {
                                HtmlTableCell   c   =   new   HtmlTableCell();
                                c.Controls.Add(new   LiteralControl( "行 "   +   j.ToString()   +   ",列 "   +   i.ToString()));
                                r.Cells.Add(c);
    &nb