当前位置:编程学习 > C#/ASP.NET >>

怎么获得每行的值 动态添加的啊 急急急!!!!


        int tableRows = rows;  //接收用户设置行数
        int tableCells = 4;  //4列
        int tbId = 1; //由于一行有多个Textbox,要设置每个TextBox的ID唯一性。

        for (int i = 1; i <= tableRows; i++)
        {
            TableRow tableRow = new TableRow();
            for (int j = 1; j <= tableCells; j++)
            {
                switch (j)
                {
                    case 1:  //第一列
                        TableCell tableCell1 = new TableCell();
                        tableCell1.BorderWidth = Unit.Pixel(1);
                        FileUpload fileUpload = new FileUpload();
                        fileUpload.ClientIDMode = ClientIDMode.Static;
                        fileUpload.ID = "FileUpload" + i.ToString();
                        tableCell1.Controls.Add(fileUpload);
                        tableRow.Cells.Add(tableCell1);
                        break;
                    case 2: //第二列
                        TableCell tableCell2 = new TableCell();
                        tableCell2.BorderWidth = Unit.Pixel(1);
                        TextBox textBox1 = new TextBox();
                        textBox1.ClientIDMode = ClientIDMode.Static;
                        textBox1.ID = "TextBox" + tbId.ToString();
                        tbId = tbId + 1;
                        tableCell2.Controls.Add(textBox1);
                        tableRow.Cells.Add(tableCell2);
                        break;
                    case 3: //第三列
                        TableCell tableCell3 = new TableCell();
                        tableCell3.BorderWidth = Unit.Pixel(1);
                        TextBox textBox2 = new TextBox();
                        textBox2.ClientIDMode = ClientIDMode.Static;
                        textBox2.ID = "TextBox" + tbId.ToString();
                        tbId = tbId + 1;
                        tableCell3.Controls.Add(textBox2);
                        tableRow.Cells.Add(tableCell3);
                        break;
                    case 4: //第四列
                        TableCell tableCell4 = new TableCell();
                        tableCell4.BorderWidth = Unit.Pixel(1);
                        DropDownList dropDownList = new DropDownList();
                        dropDownList.ClientIDMode = ClientIDMode.Static;
                        dropDownList.ID = "DropDownList" + i.ToString();
                        dropDownList.DataSource = PhotoAlbum();
                        dropDownList.DataBind();
                        tableCell4.Controls.Add(dropDownList);
                        tableRow.Cells.Add(tableCell4);
                        break;
                }
            }

            TableUploadlayout.Rows.Add(tableRow);
        } --------------------编程问答-------------------- 没看明白,。。。 --------------------编程问答--------------------
引用 1 楼 zhouqinghe24 的回复:
没看明白,。。。

获取到动态生成后行的数据  添加到数据库 --------------------编程问答-------------------- 用js吧。。。 --------------------编程问答-------------------- 你再用JS 循环table  然后把每行的数据提取出来

然后用ajax提交到后台 
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,