Gridview Data

I have a GridView with which I am populating 3 columns with data from a SQL table. The columns are populated after an ontextchanged event. The data populates the columns just fine, however the data is erased when I add a new row to the GridView by clicking the update button. The data returns if I click on the GridView edit button. The columns I am manually completing do not erase after adding a row. Also, it appears that the data I am populating from the SQL table appears in the GridView column as a label instead of inside of the column text box.

How can I keep the data from erasing?


Whenever there is a postback, the gridview retrieves the data from the Form Data.
I recommend you to modify the GridView in the form data itself by using the FormData object:


System.Data.DataRow newRow = this.FormData.Tables["REQUEST_GRIDVIEW1"].NewRow();
newRow[0] = "Value of 1st column";
newRow[1] = "Value of 2nd column";
newRow[2] = "Value of 3rd column";


Good morning. Thanks for your response. I was able to resolve the issue late yesterday. All it took was changing this:

((TextBox)this.REQUEST_GRIDVIEW1.Rows[this.REQUEST_GRIDVIEW1.EditIndex].Cells[2]).Text = SqlReader[0].ToString();

((TextBox)this.REQUEST_GRIDVIEW1.Rows[this.REQUEST_GRIDVIEW1.EditIndex].Cells[3]).Text = SqlReader[1].ToString();

To this:

((TextBox)this.REQUEST_GRIDVIEW1.Rows[this.REQUEST_GRIDVIEW1.EditIndex].Cells[2].Controls[0]).Text = SqlReader[0].ToString();

((TextBox)this.REQUEST_GRIDVIEW1.Rows[this.REQUEST_GRIDVIEW1.EditIndex].Cells[3].Controls[0]).Text = SqlReader[1].ToString();

Adding .Controls[0]).Text to both gridview cell assignments allowed the gridview columns textbox to be populated with sql data instead of populating the column with sql data as a label. I don’t know if that makes a lot of sense, but that is the best way I can describe how the sql data was appearing in the gridview before it disappeared on update.

@eddy.daouk Hello eddy , i need to retrieve data from sql table and insert it into gridview , i 'am beginner in workflowgen and i don’t know how to do that . Can you help me please ? thanx