Need To Click Edit Button Twice On Datagrid

Discussion in 'ASP .Net' started by =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 14, 2005.

  1. 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
    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 14, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?SmViQnVzaGVsbA==?=

    J. Jespersen Guest


    > 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
    J. Jespersen, Oct 14, 2005
    #2
    1. Advertising

  3. 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);
    }
    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 14, 2005
    #3
  4. FYI: AutoEventWireup="false"
    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 15, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mike parr
    Replies:
    1
    Views:
    464
    Marina
    May 20, 2004
  2. dilbert
    Replies:
    0
    Views:
    465
    dilbert
    Jan 28, 2008
  3. dilbert
    Replies:
    0
    Views:
    448
    dilbert
    Jan 28, 2008
  4. Frank Kurka
    Replies:
    8
    Views:
    304
  5. Jaime Stuardo

    GridView control enters edit mode when I click Edit link twice

    Jaime Stuardo, Apr 7, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    390
    Jaime Stuardo
    Apr 7, 2006
Loading...

Share This Page