recently I changed my GridView so it was able to add rows dynamically. The problem is, when I insert the data, I'm getting blank value at first. I'm unable to get the details of my labels.text , but are able to get the text box value the first time. When the loop continues, I get 1 row of value from the label and 2 rows of value from the text box.
GridViewRow row = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal); TableHeaderCell cell = new TableHeaderCell(); cell.Text = "Details"; cell.ColumnSpan = 3; row.Controls.Add(cell); cell = new TableHeaderCell(); cell.Text = "Year 2018"; cell.ColumnSpan = 4; row.Controls.Add(cell); cell = new TableHeaderCell(); cell.ColumnSpan = 4; cell.Text = "Year 2019"; row.Controls.Add(cell); cell = new TableHeaderCell(); cell.Text = "Others"; cell.ColumnSpan = 3; row.Controls.Add(cell);
Label CenterId = (Label)row.FindControl("CenterId") as Label; string CenterId_no = Convert.ToString(CenterId.Text); TextBox txt_lastyearonDate = (TextBox)row.FindControl("txt_lastyearonDate") as TextBox; float py_ondte = float.Parse(txt_lastyearonDate.Text);
Convert.ToString(CenterId.Text);
Label CentreID = row.Cells[1].Controls[0] as Label;
string s = (string) row.Cells[1].Value;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)