Need To Click Edit Button Twice On Datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm a novice building a datagrid crud page and I have ASP.NET Cookbook and 4
web references to assist me. I am using VS 2003 so the code is not "inline".

My problem is that when I click the Edit button on the grid nothing happens.
Then I click it again and the expected happens i.e. the affected row is
re-presented in text boxes.

Both clicks of the Edit button cause a Page_Load but only the first fires
the Edit event (where grid.EditItemIndex is set).

Any help greatly appreciated.
jebbushell*yahoo*com
 
My problem is that when I click the Edit button on the grid nothing
happens.
Then I click it again and the expected happens i.e. the affected row is
re-presented in text boxes.

Sounds like you're doing a .databind in your page_load without checking to
see if "page.isPostback". Try something like....

(in page_load)
if not page.isPostback then
myDatagrid.databind
end if

(in edit command)
myDatagrid.databind

Should get you on the right track.

Jeppe Jespersen
Denmark
 
I don't think it's that. FYI the "database" I'm using is a directory
containing .txt files configured as a server via Jet. Of couse, that should
be irrelevant, but it has to be unusual so i thought I'd better tell. Here's
the Page_Load:

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
oleDbDataAdapter1.Fill(dsPumps1);
dgPumps.DataBind();
}
dgPumps.EditCommand +=
new DataGridCommandEventHandler(this.dgPumps_Edit);
dgPumps.CancelCommand +=
new DataGridCommandEventHandler(this.dgPumps_Cancel);

dgPumps.ItemCommand +=
new DataGridCommandEventHandler(this.dgPumps_Command);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top