GridView RowUpdating not retrieving newvalues (only oldvalues)

S

s.bussing

Hi, I have been struggling with the GridView the whole day, but can not
get this solved.

The rowupdating event in my Gridview doesn't give me the new values
only the old ones.
In my GridView I do not use a DataSourceObject and can therefore not
use e.NewValues or e.OldValues
The columns used are template columns


Thx

Below some codesnippets I use:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
else
{
if (ViewState["BestellingAfdeling"] != null)
_BeBestellingAfdeling =
(BEBestellingAfdeling)ViewState["BestellingAfdeling"];
}
}


protected void grvCategorie_UpdatingCommand(object sender,
GridViewUpdateEventArgs e)
{
int _CategorieId =
Convert.ToInt32(grvCategorie.DataKeys[e.RowIndex]["fldCategorieId"]);
BEBestellingAfdeling.tblCategorieRow _drCategorieRow =
_BeBestellingAfdeling.tblCategorie.FindByfldCategorieID(_CategorieId);

if (_drCategorieRow != null)
{
_drCategorieRow.BeginEdit();
_drCategorieRow.fldOmschrijving =
((TextBox)grvCategorie.Rows[e.RowIndex].FindControl("tbxOmschrijving")).Text;
_drCategorieRow.fldStatus =
((CheckBox)grvCategorie.Rows[e.RowIndex].FindControl("cbxStatus")).Checked;
_drCategorieRow.EndEdit();
}

grvCategorie.EditIndex = -1;
ReBindDataToControl();
}
 
S

s.bussing

Nevermind, see below for the problem.

In my GV I use ImageButton to handel edit, cancel and update logic. In
my codebehind file I have a procudure checking for the e.command
argument in the GridView_RowCommand. The problem was that in this
particular procedure I did a ReBind from the GV, which means, I lost
all my changes and could only see the old (original) values.

The next link helped me a lot:

http://groups.google.nl/group/microsoft.public.dotnet.framework.aspnet/browse_frm/thread/
684ca465e9bcdbac/b712f23981099d17?lnk=st&q=Gridview+editing+without+ObjectDataSource&rnum=7#b712f23981099d17

In summary: due to rebinding on the wrong moment I lost my changes.
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top