On 16 Apr, 21:18, "qa4ever" <qa4e...@gmail.com> wrote:
> Hi gurus!
>
> I have now got a bit further.
>
> The Edit editbox apears and *having pressed Update I see gui change backto
> a static text (ie the editbox disapere) .
>
> However in both eventhandlers for RowUpdating and RowUpdated * * * both
> e.NewValues and OldValues are empty !
>
> Any Guess what's wrong? Do I need to bind the column "Quantity" to get the
> value after updating? If so where and when?
>
> Strange that the RowDeleting.... works perfect, I had guessed updating thru
> the gridview would be more tricky than deleting, but this is ridiculous.
>
> Thanks!,
> QA4Ever
>
> "qa4ever" <qa4e...@gmail.com> wrote in message
>
> news:...
>
>
>
> > Hi Gridview gurus
>
> > I got a Gridview that is populated from Datatable, held in a *Session.
> > Pressing delete successfully deletes the row.
>
> > Problem is that pressing Edit, *no expected editbox apear instead nothing
> > happens except for my *RowEditingBasket event handler is called and I can
> > see the value of the gridview that I hoped now had a editobox enabling
> > editing.
>
> > protected void RowEditingBasket(object sender, GridViewEditEventArgs e)
> > * *{
> > * * * * * * * *String newQuantity =
> > GridViewBasket.Rows[e.NewEditIndex].Cells[4].Text;
>
> > <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
> > Runat="Server">
>
> > * *<asp:GridView ID="GridViewBasket" runat="server"
> > * *AutoGenerateDeleteButton="true"
> > * *autogeneratecolumns="true"
> > * *autogenerateeditbutton="true"
> > * *datakeynames="IDRow"
> > * *onrowupdating="RowUpdatingBasket"
> > * *onrowdeleting="RowDeletingBasket"
> > * *Caption="Your basket contain the following items:"
> > * *onrowediting="RowEditingBasket" *>
> > * *<EditRowStyle BackColor="Yellow" />
> > * *<AlternatingRowStyle BorderStyle="Inset" />
>
> > * *</asp:GridView>
>
> > I.e delete works fine but not updating /editing the same
> > * *public void DoRowDeletingBasket ( object o, GridViewDeleteEventArgs e)
> > * *{
> > * * * *dt = (DataTable)Session["data"];
> > * * * *dt.Rows.RemoveAt(e.RowIndex);
> > * * * *dt.AcceptChanges(); *//commit
> > * * * *Session["data"] = dt;
>
> > Thank you,
> > QA4ever- Hide quoted text -
>
> - Show quoted text -
Recommend the use of an ObjectDataSource in conjunction with a newly
declared class object. If not familiar look it up and learn how to use
it.
With that you can put all the data handling code in the class file
(i.e. create and maintain the DataTable stored in Session state). You
will need to write procedures for retrieving the table (select
method), updating and deleting rows using values as passed as
parameters but there will be no need to bother about event handlers or
getting data to and from the GridView. The ObjectDataSource will do
all that for you.
Good luck
|