protected override object SaveViewState() { var viewState = new object[2]; //Saving the dropdownlist value to the View State viewState[0] = txtmonday.Text; return viewState; } protected override void LoadViewState(object savedState) { //Getting the dropdown list value from view state. if (savedState is object[] && ((object[])savedState).Length == 2) { var viewState = (object[])savedState; //var count = int.Parse(viewState[0].ToString()); CreateDynamicControl(); base.LoadViewState(viewState[1]);//cheged from 1 to 0 } else { base.LoadViewState(savedState); } } public void CreateDynamicControl() { var txtmonday1 = new TextBox(); var textboxCell = new TableCell(); var tableRow = new TableRow(); tableRow.Cells.Add(textboxCell); textboxCell.Controls.Add(txtmonday1); tbl.Rows.Add(tableRow); // txtmonday1 = (TextBox)txtmonday1; // int count = GridView1 // GridView1.Controls.Add(txtmonday1); }
protected void btnupdate_Click(object sender, EventArgs e) { foreach (TableRow row in tbl.Rows) { var textbox = row.Cells[0].Controls[0] as TextBox; } } protected void btnedit_Click(object sender, EventArgs e) { // txtmonday.ID = "txtmonday1"; int index = GridView1.EditIndex; Button btn = (Button)sender; GridViewRow gvr = (GridViewRow)btn.NamingContainer; int getindex = gvr.RowIndex; string id = GridView1.Rows[getindex].Cells[4].Text; TextBox txtmonday = new TextBox(); txtmonday.ID = "Textbox1"; string get = GridView1.HeaderRow.Cells[3].Text.ToString(); txtmonday.Text = GridView1.Rows[getindex].Cells[3].Text; Page.Form.Controls.Add(txtmonday); GridView1.Rows[getindex].Cells[3].Controls.Add(txtmonday); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)