<td> <asp:Button ID="btnAddmoreDocs" runat="server" CssClass="Button" Text="Add More" OnClick="btnAddmoreDocs_Click" /> </td>
protected void btnAddmoreDocs_Click(object sender, EventArgs e) { //if (Convert.ToString(ViewState["Generated"]) != "true") { AddUserControl(); } } private void AddUserControl() { Table tbldynamic = new Table(); int i=1; if (ViewState["i"] == "0" || ViewState["i"] == "" || ViewState["i"] == null) { ViewState["i"] = 1; } else { i = Convert.ToInt16(ViewState["i"]) + 1; } for (int j = 1; j <= i; j++) { TableCell tc = new TableCell(); TableCell tclabel = new TableCell(); TableCell tclabelDocName = new TableCell(); TableCell tcTextDocName = new TableCell(); TableCell tcFileUpld = new TableCell(); TableRow tr = new TableRow(); //CheckBox _checkbox = new CheckBox(); Label LbelType = new Label(); LbelType.ID = "lbltype" + j; LbelType.Text = "Document Type :"; Label lblDocName = new Label(); lblDocName.ID = "lblDocName" + j;// ViewState["i"]; lblDocName.Text = "Document Name :"; DropDownList ddltype = new DropDownList(); ddltype.ID = "ddlDocumntType" + j;// ViewState["i"]; ddltype.Text = "Document Type"; TextBox txtDocName = new TextBox(); txtDocName.ID = "txtDocnm" +j; Session[txtDocName.ID] = txtDocName; FileUpload FileUpd = new FileUpload(); FileUpd.ID = "filUpldDoc" + j;// ViewState["i"]; // _checkbox.ID = "chkDynamicCheckBox" + i; //_checkbox.Text = "Checkbox" + i; tc.Controls.Add(ddltype); tclabel.Controls.Add(LbelType); tclabelDocName.Controls.Add(lblDocName); tcTextDocName.Controls.Add(txtDocName); tcFileUpld.Controls.Add(FileUpd); tr.Cells.AddAt(0, tclabel); tc.Width = 100; tr.Cells.AddAt(1, tc); tr.Cells.AddAt(2, tclabelDocName); string textboxID = "txtDocnm" + j; TextBox checkIfTextBox = (TextBox)Session[textboxID]; if (checkIfTextBox != null) { txtDocName.Text = checkIfTextBox.Text; } //if (string.IsNullOrEmpty(Request.Form["txtDocnm" + j.ToString()])) //{ // txtDocName.Text = Request.Form["txtDocnm" + j.ToString()]; //} tr.Cells.AddAt(3, tcTextDocName); tr.Cells.AddAt(4, tcFileUpld); tbldynamic.Rows.Add(tr); ViewState["i"] = j;// (Convert.ToInt16(ViewState["i"]) + 1).ToString(); } pnlStudDocumnts.Controls.Add(tbldynamic); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)