Gridview pressing Edit do not show any editable editbox in grid, while delete works fine

Discussion in 'ASP .Net Web Controls' started by qa4ever, Apr 15, 2008.

  1. qa4ever

    qa4ever Guest

    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
     
    qa4ever, Apr 15, 2008
    #1
    1. Advertising

  2. qa4ever

    Stan Guest

    Re: Gridview pressing Edit do not show any editable editbox in grid,while delete works fine

    On 15 Apr, 15:38, "qa4ever" <> wrote:
    > 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


    From information given cannot tell cause of problem is but even if it
    did work newQuantity will be wrong value. RowEditing event occurs
    before edit row appears not afterward.
     
    Stan, Apr 16, 2008
    #2
    1. Advertising

  3. qa4ever

    qa4ever Guest

    Hi gurus!

    I have now got a bit further.

    The Edit editbox apears and having pressed Update I see gui change back to
    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" <> 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
     
    qa4ever, Apr 16, 2008
    #3
  4. qa4ever

    Stan Guest

    Re: Gridview pressing Edit do not show any editable editbox in grid,while delete works fine

    On 16 Apr, 21:18, "qa4ever" <> 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" <> 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
     
    Stan, Apr 16, 2008
    #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. =?Utf-8?B?a2Vu?=
    Replies:
    1
    Views:
    10,349
    Wiktor Zychla [C# MVP]
    Jan 23, 2006
  2. MPBroida
    Replies:
    5
    Views:
    665
    John Carson
    Oct 25, 2003
  3. bill
    Replies:
    2
    Views:
    425
    P.J. Plauger
    May 25, 2004
  4. JDeats
    Replies:
    2
    Views:
    584
    JDeats
    Sep 11, 2007
  5. Harishankar
    Replies:
    0
    Views:
    298
    Harishankar
    Mar 31, 2010
Loading...

Share This Page