using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { List<TextBox> ArrayTextBox; protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { CreateTextBox(); int nrows; int ncells; //int numrows; //int numcells; int i = 0; int j = 0; TableRow r; TableCell c; // Generate rows and cells nrows = Convert.ToInt32(this.txtRow.Text); ncells = Convert.ToInt32(this.txtCell.Text); //numrows = Convert.ToInt32(DropDown1.SelectedItem.Value); //numcells = Convert.ToInt32(DropDown2.SelectedItem.Value); for (j = 0; j <= nrows - 1; j++) { r = new TableRow(); for (i = 0; i <= ncells - 1; i++) { c = new TableCell(); TextBox aTextBox = new TextBox(); //aTextBox.ID = "aTextBox" + i.ToString(); //c.Controls.Add(aTextBox); //c.Controls.Add(new LiteralControl("row " + j + ", cell " + i)); c.Controls.Add(aTextBox); r.Cells.Add(c); } Table1.Rows.Add(r); } } //ปิด class Button1_Click protected void CreateTextBox() { if (txtNumText.Text != ""){ int count = int.Parse(txtNumText.Text); if (count > 0){ ArrayTextBox = new List<TextBox>(); for (int i = 0; i < count; i++) { TextBox aTextBox = new TextBox(); aTextBox.ID = "aTextBox" + i.ToString(); ArrayTextBox.Add(aTextBox); RequiredFieldValidator aRequiredFieldValidator = new RequiredFieldValidator(); aRequiredFieldValidator.ControlToValidate = "aTextBox" + i.ToString(); aRequiredFieldValidator.ErrorMessage = "*"; PlaceHolder1.Controls.Add(aTextBox); //PlaceHolder1.Controls.Add(aRequiredFieldValidator); PlaceHolder1.Controls.Add(new LiteralControl(@"<br />")); } //Button ButtonShow = new Button(); //ButtonShow.Text = "Show"; //ButtonShow.Click += new EventHandler(ButtonShow_Click); //PlaceHolder1.Controls.Add(ButtonShow); //TextBox1.ReadOnly = true; //Button1.Enabled = false; } //ปิด if Count } //ปิด if txtNumText } // ปิด class CreateTextBox } //ปิด public class _Default } //ปิด namespace
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง