Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old September 7th, 2008, 12:15 AM
Cralis
Guest
 
Posts: n/a
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  
Old September 7th, 2008, 05:55 AM
Ken Cox [MVP]
Guest
 
Posts: n/a
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.comwrote in message
news:bdafdeca-d5da-451c-a636-24fb02b11cac@a3g2000prm.googlegroups.com...
Quote:
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  
Old September 7th, 2008, 07:55 AM
Cralis
Guest
 
Posts: n/a
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  
Old September 9th, 2008, 08:05 AM
Cralis
Guest
 
Posts: n/a
Default Re: GridView and Updating

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

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles