if (int.TryParse(TextBox1.Text.Trim(), out numOfColumns) && int.TryParse(TextBox2.Text.Trim(), out numOfRows)) { //Generate the Table based from the inputs GenerateTable(numOfColumns, numOfRows, "eng"); viewstate["ko"]=table1; } private void GenerateTable(int colsCount, int rowsCount, string cat) { try { //Table t = (Table)table1; //Page.Form.Controls.Add(table1); for (int i = 0; i < rowsCount; i++) { TableRow row = new TableRow(); for (int j = 0; j < colsCount; j++) { TableCell cell = new TableCell(); //TextBox tb = new TextBox(); DropDownList dl = new DropDownList(); FileUpload ful = new FileUpload(); // Set a unique ID for each TextBox added //tb.ID = "tb_" + i + "Col_" + j; dl.ID = cat + "dl_" + i + "Col_" + j; ful.ID = cat + "ful_" + i + "Col_" + j; SqlCommand cmd = new SqlCommand(); cmd.Connection = con; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter("select PaperName from [7Seas_News_displayT]", con); da.Fill(ds, "[7Seas_News_displayT]"); con.Open(); cmd.CommandText = "select PaperName from [7Seas_News_displayT]"; DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); dl.DataSource = dt; dl.DataTextField = "PaperName"; //dl.DataValueField = "Sno"; dl.DataBind(); con.Close(); // Add the control to the TableCell //cell.Controls.Add(tb); table1.Controls.Add(dl); table1.Controls.Add(ful); // Add the TableCell to the TableRow } // Add the TableRow to the Table } } catch { } //Creat the Table and Add it to the Page }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)