Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1967
  • Last Modified:

I need to click the edit button twice to get the GridView into Edit mode?

Hi,


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"];

GridView.DataBind();


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?


Thanks,

Hang
0
hanglam
Asked:
hanglam
  • 2
  • 2
1 Solution
 
informaniacCommented:
You sure you have checked the

if(!isPostBack) before binding the Gridview?
0
 
hanglamAuthor Commented:
Hi informaniac,

Thanks for the reply, I have check the (!Page.IsPostback)  before binding the GridView.

Does anyone else have any other suggestions? Any help is appreciated.

Thanks,
Hang
0
 
informaniacCommented:
are you assigning the Datasource in RowEditing event?

as in

Gv.DataSource = dt;
Gv.DataBind();

Since you are saying the Gridview disappears after databind in RowEditing, I'm guessing the datasource is getting set to null.
0
 
hanglamAuthor Commented:
Hi informaniac,

Yes I did that in the RowEditing event,

GridView.DataSource = Dataset.Table["TestDataTable"];
GridView.DataBind();

Hang
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now