可以用这些控件实现
也可以用panel来实现
添加按钮事件里定义出对象,然后panel1.controls.add()

解决方案 »

  1.   

    楼主是想做批量录入建议用DataGrid来做吧,这里要用到模版,代码还有比较多的
      

  2.   


    我用的vs2008,没有datagrid了
      

  3.   

    诸位能说得详细点吗,我asp.net不太熟
      

  4.   

    这是我的代码,你自己修改下就好了,
    前台:
    <style>
    #tab {
    border:1px solid #a4d140;
    border-collapse:collapse;
    width:400px;
    }
    #tab th{
    border:1px solid #aaaaaa;
    background:#cce98b;
    border-collapse:collapse;
    text-align:left;
    }
    #tab td{
    border:1px solid #cce98b;
    border-collapse:collapse;
    }
    .txt{
       border:1px solid #888;
    background:#ECE9D8;
    }
    .checkBg{
    border:1px solid #a4d140;
    background:#ECE9D8;
    }
    .button {
       border:1px solid #a4d140;margin:5px 0px;
       width:80px;background:#cce98b;height:22px;line-height:22px;
    }
    </style>
    <script language="javascript" type="text/javascript">
    function $(id) {return document.getElementById(id);}
    function $F(name){return document.getElementsByTagName(name);}function add(){
    var otr = document.getElementById("tab").insertRow(-1);
    var checkTd=document.createElement("td");
    checkTd.innerHTML = '<input name="delx"  type="button" class="button" onclick="del();" value="删除" />';
    var otd1 = document.createElement("td");
    otd1.innerHTML = '<input type="file" id="File1" name="File1" size="30"  runat="server"  />';otr.appendChild(checkTd);
    otr.appendChild(otd1); 
    }
    function del()
    {
        var dgTable=document.getElementById("tab").rows;
        var pp=event.srcElement; 
            
        for (var i=0; i < dgTable.length; i++)
        {
             if(pp==dgTable[i].cells[0].getElementsByTagName("input")[0])
             { 
                document.getElementById("tab").deleteRow(i);
             } 
             
        }

    </script>
    <input name="addv_btn" id="addv_btn" type="button" class="button" onclick="add();" value="添加" /> <table id="tab" name="tab" >
    <tr>
    <th width="100px"></th>
    <th width="300px">文件</th>
    </tr>
    </table>
    <asp:Button ID="Button1" runat="server" CssClass="button" Text="确认上传" OnClick="Button1_Click" /><br />
    <asp:Label ID="errorLabel" runat="server"></asp:Label>
    后台:    static public string _SavePath;
        static public string[] FileNames;
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        public string[] AllFiles
        {
            get {
                return FileNames;
            }
        }
        public string SavePath
        {
            set
            {
                 _SavePath=value;
            }
        }
        void GetControlsToUpload()     
        {
            HttpFileCollection files = HttpContext.Current.Request.Files;
            FileNames=new string[files.Count];
            for (int i = 0; i < files.Count; i++)
            {
                HttpPostedFile file = files[i];
                UpFile(file,i);
                    
            }  
        }
        protected void UpFile(HttpPostedFile File,int Index)
        {
            if (File.FileName != ""&&File.FileName !=null)
            {
                string oldName = File.FileName.Substring(File.FileName.LastIndexOf('\\') + 1, File.FileName.Length - File.FileName.LastIndexOf('\\')-1);
                string newName = DateTime.Now.ToString("yyyyMMddhhmmss") + "_" +oldName ;
                try
                {
                    File.SaveAs(Server.MapPath(_SavePath + newName));
                    errorLabel.Text += File.FileName+"上传成功<br>";
                    FileNames[Index]=newName;            }
                catch
                {
                    errorLabel.Text += File.FileName+"上传失败<br/>";
                }        }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            GetControlsToUpload(); 
        }
      

  5.   

    http://blog.csdn.net/mngzilin/archive/2009/08/19/4463988.aspx
      

  6.   

    TextBox tb=new TextBox();
    tb.text="";
    tb.ID="";
    Panel.controls.add(tb);
    大概是这个过程
      

  7.   


    //添加
    for (int i = 0; i < 5; i++ )
            {
                FileUpload fi = new FileUpload();
                fi.ID = "Fi" + i.ToString();
                Panel1.Controls.Add(fi);
                Panel1.Controls.Add(new LiteralControl("</br>"));
            }//移除
    Panel1.Controls.Clear(); 
    取值的话用FindControl方法 string filename=((FileUpload)Panel1.FindControl("Fi1")).FileName;
      

  8.   


    点“添加”按钮时弹出一个新的窗体让他输入数据不好吗?
    隐藏? visible?
      

  9.   

    用GridView的模板列应该很方便
      

  10.   

    使用js insertRow实现添加
    或者这些控件本来就存在的 然后放在div中控制显示与否(display)
    如果你用动态生成控件的话,就必须放在Page_Init并且不可添加!IsPostBack,否则控件回发丢失
      

  11.   

    XML组织数据,
    JS控制控件,
      

  12.   

    多线程操作,通过add控件的方法