GridView and Updating - DOTNET

This is a discussion on GridView and Updating - DOTNET ; Hi guys, I am new to GridViews.. I have a gridview that displays 3 columns. Description, MahUsed and a calculated % Used field. When I click Edit on the row, the MahUsed goes into Edit mode, and I can change ...

+ Reply to Thread
Results 1 to 4 of 4

GridView and Updating

  1. Default GridView and Updating

    Hi guys,

    I am new to GridViews.. I have a gridview that displays 3 columns.
    Description, MahUsed and a calculated % Used field.

    When I click Edit on the row, the MahUsed goes into Edit mode, and I
    can change the value.

    Now the problems start.

    I click 'Update', and I end up with the original value.

    The ObjectDataSource has an Update method, that points to this
    function:

    public void UpdatePackUsage(int Id, int Mahusage)
    {
    dbfb.UpdatePackUsage(Id, Mahusage);
    }

    If I put a breakpoint on this function, it is getting hit, however,
    the value for Mahusage is always the ORIGINAL value. That is, it never
    changes to what I have typed in the edit box.

    Do I need to use the RowUpdating event? I'm not at the moment, but am
    wondering if I need to do something like:

    protected void GridView1_RowUpdating(object sender,
    GridViewUpdateEventArgs e)
    {
    FlightBatteryService fbs = new FlightBatteryService();
    fbs.UpdatePackUsage(int.Parse(e.Keys["Id"].ToString()),
    int.Parse(e.NewValues["Mahusage"].ToString()));
    DataBind();
    }

    I tried that, and removed the UpdateMethod from the ODS, but then I
    get an error about requiring an update method if editing is to be
    used.

    Hope someone can assit.

  2. Default Re: GridView and Updating

    What's in your Page_Load event? Are you remembering not to only fill the
    grid there when it's NOT a postback?

    Ken

    "Cralis" <info@listerhome.com> wrote in message
    news:bdafdeca-d5da-451c-a636-24fb02b11cac@a3g2000prm.googlegroups.com...
    > Hi guys,
    >
    > I am new to GridViews.. I have a gridview that displays 3 columns.
    > Description, MahUsed and a calculated % Used field.
    >
    > When I click Edit on the row, the MahUsed goes into Edit mode, and I
    > can change the value.
    >
    > Now the problems start.
    >
    > I click 'Update', and I end up with the original value.
    >
    > The ObjectDataSource has an Update method, that points to this
    > function:
    >
    > public void UpdatePackUsage(int Id, int Mahusage)
    > {
    > dbfb.UpdatePackUsage(Id, Mahusage);
    > }
    >
    > If I put a breakpoint on this function, it is getting hit, however,
    > the value for Mahusage is always the ORIGINAL value. That is, it never
    > changes to what I have typed in the edit box.
    >
    > Do I need to use the RowUpdating event? I'm not at the moment, but am
    > wondering if I need to do something like:
    >
    > protected void GridView1_RowUpdating(object sender,
    > GridViewUpdateEventArgs e)
    > {
    > FlightBatteryService fbs = new FlightBatteryService();
    > fbs.UpdatePackUsage(int.Parse(e.Keys["Id"].ToString()),
    > int.Parse(e.NewValues["Mahusage"].ToString()));
    > DataBind();
    > }
    >
    > I tried that, and removed the UpdateMethod from the ODS, but then I
    > get an error about requiring an update method if editing is to be
    > used.
    >
    > Hope someone can assit.




  3. Default Re: GridView and Updating

    I'm doing this on PageLoad:

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    FlightLogService fls = new FlightLogService();
    oFlightLog flight =
    fls.Get(int.Parse(Session["selectedflightid"].ToString()));

    lblAircraft.Text = flight.Aircraft;
    lblConfiguration.Text = flight.Configuration;
    lblCurveType.Text = flight.Curve;
    lblDate.Text = flight.Flightdate.ToString("dd MMMM
    yyyy");
    lblStyle.Text = flight.Flyingstyle;
    tbMin.Text = flight.Minutes;
    tbSeconds.Text = flight.Seconds;
    }
    }

    So, nothing about the grid...
    You're maybe onto something though... But I don't do anything to
    populate the grid. I just setup the ODS....
    Is there a way to stop it from what it's doing?

  4. Default Re: GridView and Updating

    No ideas?
    I think I need to use the Row_Updating event.. but it seems strange...

+ Reply to Thread