本文介绍了如何增加表格单元格的宽度(通过动态表格)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

foreach (string item in list)
            {

                for (int i = 0; i < 1; i++)
                {

                    TableRow row = new TableRow();
                    for (int j = 0; j < 2; j++) // Loop for Column
                    {
                        TableCell cell = new TableCell();

                        Label lbl = new Label();
                        lbl.Text = item;
                        cell.Controls.Add(lbl);

                        TextBox tb = new TextBox();
                        tb.ID = "txtBox1" + i.ToString();
                        RequiredFieldValidator reqfldVal = new RequiredFieldValidator();
                        reqfldVal.ID = "RequiredValidator" + i;
                        reqfldVal.ControlToValidate = "txtBox1" + i;
                        reqfldVal.ErrorMessage = "Not Empty";
                        reqfldVal.SetFocusOnError = true;
                        cell.Controls.Add(tb);
                        row.Cells.Add(cell);
                    }
                    k++;

                    table.Rows.Add(row);


                }
            }



在这里,我在单元格中同时添加了标签和文本框.如何分隔两个单元格.
TableCell cell = new TableCell();



here i am add both lable and textbox in cell. how to separate two cells.
TableCell cell = new TableCell();

推荐答案

TableCell cell = new TableCell();
cell.Width = 100;



这样,您可以根据需要增加表的数量.



That way you can increase your table as much as you want..


TableCell cell = new TableCell();
td.Width = Unit.Percentage(100);



祝一切顺利

谢谢与问候
Sandeep



All the best

Thanks&&Regards
Sandeep



这篇关于如何增加表格单元格的宽度(通过动态表格)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 10:04