I need to click the edit button twice to get the GridView into Edit mode?
Posted on 2012-08-18
I created a dataset manually that contains a datatable with rows, columns and data. I used a GridView to display the dataset. (I'm not using a SQLDataSource at all in my application).
Basically this is what I do:
GridView.DataSource = Dataset.Tables.["TestDataTable"];
In the GridView, I used an <asp:BoundField DataFiled="Field1" HeaderText"Field1"> to bound one of the columns in the DataSet to display in the DataGrid. There are other <asp:BoundField> tags for the other columns as well but I'm just trying to give you an idea of how the GridView looks, basic <asp:BoundField> tags.
I set the the GridView.AutoGenerateEditButton = true.
But when I click on the Edit Button, I have to click the Edit Button twice to get into Edit mode and the data is not bound to the Textbox once it is in Edit mode.
I tried to using the GridView_RowEditing event handler to issue the Gridview.Databind() command again but it just make my GridView disappears from the screen.
I plan to use the DataSet as my main DataSource for the DataGrid, any updates, I will do to the DataSet only and not to any database. My application is a stand-alone application that does not connect to a database server. It just collects information and save the information into a programmatically construted DataSet.
So my problem is:
1. Why do I have to click the Edit Button twice to get into Edit Mode and why is the data not being bound to the TextBox once it is in Edit Mode?
2. Why when I issued a GridView.DataBind() command in the GridView_RowEditng event handler, does my Gridview disappears from the screen?