OnRowUpdating

Last post 05-09-2008 4:11 PM by Graphfixz. 8 replies.

Sort Posts:

  • OnRowUpdating

    05-08-2008, 4:21 PM
    • Loading...
    • Graphfixz
    • Joined on 01-10-2003, 11:23 AM
    • Posts 337

    I have a nested row that I am having some trouble with. When I try to edit a row in the nested gridview; I never hit my onRowUpdating method.

    I can hit my OnRowEditing method just fine. I can hit my OnRowCanceling Method. I can even hit the OnSelectedIndexChanged method just find. But OnRowUpdating.. naw-uh! Why can't I hit everything just fine except the OnRowUpdating.

     as i step through it, it does everything I am telling it to do and I guress right before it is supposed to hit the OnRowUpdating method it renders the page.

    I do have the OnRowUpdating property set on the gridview, I do have the datakeynames property set. oh and what is even more weired is that I can insert a new row (yet another command that works) and insert a new record (yet another command that works).

    Please help!!!

    Thanks!

    Graphfixz Data & Web Design
    http://www.graphfixz.com
  • Re: OnRowUpdating

    05-08-2008, 4:25 PM
    • Loading...
    • geosync
    • Joined on 03-26-2006, 8:44 PM
    • Boston, MA, USA
    • Posts 322

    OnRowUpdating ought to fire after you click the Update button. 

    Are you saying that this is not happening?

    ~ Timing is Everything! ~
  • Re: OnRowUpdating

    05-08-2008, 4:29 PM
    • Loading...
    • Graphfixz
    • Joined on 01-10-2003, 11:23 AM
    • Posts 337

    Yep, when I click on Update (next to Cancel) and step through it in VS It does everyhing... hits all the methods it is supposed to and then just renders the page without even hitting on OnRowUpdating method.

    Graphfixz Data & Web Design
    http://www.graphfixz.com
  • Re: OnRowUpdating

    05-08-2008, 10:39 PM
    • Loading...
    • geosync
    • Joined on 03-26-2006, 8:44 PM
    • Boston, MA, USA
    • Posts 322

    Does your GridView control reference the code in is OnRowUpdaitng property?

    Example:

     

    <asp:GridView 
      id="ShopCartGrid" 
      DataSourceID="SqlDataSource1" 
      Runat="Server"
      AutoGenerateColumns="False"
      DataKeyNames="ID"
      OnRowUpdating="GridView1_OnRowUpdating"
    >
      <Columns>
    .
    .
    .
    
     
    ~ Timing is Everything! ~
  • Re: OnRowUpdating

    05-08-2008, 10:57 PM
    • Loading...
    • vinz
    • Joined on 10-05-2007, 11:47 AM
    • Cebu Philippines
    • Posts 4,230


    Graphfixz :

    Yep, when I click on Update (next to Cancel) and step through it in VS It does everyhing... hits all the methods it is supposed to and then just renders the page without even hitting on OnRowUpdating method.

    Can you post your GridView ASPX mark up here and the relevant codes for RowUpdating? 

    Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post fixed your problem.


  • Re: OnRowUpdating

    05-09-2008, 7:39 AM
    • Loading...
    • Graphfixz
    • Joined on 01-10-2003, 11:23 AM
    • Posts 337

    yes it does and I got a bit farther. I stripped the gridview down to its basics and I got it to hit the onRowUpdating. I still unsure as to what was causing this problem. However, now I have the problem that no values are being passed to the OnRowUpdating method. When I step throgh the code e.NewValues and e.OldValues are both empty.

    Remember this is a nested gridview and yes, I am rebinding it on PageLoad.

    Graphfixz Data & Web Design
    http://www.graphfixz.com
  • Re: OnRowUpdating

    05-09-2008, 7:54 AM
    • Loading...
    • chandan.max
    • Joined on 03-28-2008, 2:37 AM
    • India
    • Posts 155

     HI sometimes it happens...but you can do one thing...

    Just go to designview->Press f4-->Go to eventhandler --> DblClick on OnRowUpdating Event.

    Now carefully see the handler name. Is there any difference between the name in GridView property "OnRowUpdate"?

     

    "Mark as Answer" on the post that helped you.

    Chandan,
    Imfinity India Pte Ltd.
  • Re: OnRowUpdating

    05-09-2008, 10:53 AM
    • Loading...
    • Graphfixz
    • Joined on 01-10-2003, 11:23 AM
    • Posts 337

    there is no difference. I can get to the OnRowUpdating now, however the values are all empty

    Here is some of the code. I cleaned out a lot of the junk:

     aspx file:
    <asp:GridView
    OnRowUpdating="gv_RowUpdating"
    OnPreRender="gv_PreRender"
    OnRowCommand="gv_RowCommand" 
    OnSelectedIndexChanged="gv_SelectedIndexChanged"
    OnRowCancelingEdit="gv_RowCancelingEdit"
    OnRowEditing="gv_RowEditing"
    ID="gv"
    runat="server"
    DataKeyNames="Id,Title,Active"
    AutoGenerateColumns="False"
    CellPadding="0"
    TabIndex="2"
    ToolTip="TopLevels"

    <Columns>
     <asp:CommandField ShowEditButton="true" ShowSelectButton="true" SelectText="Select" EditText="Edit" CausesValidation="false" />
            <asp:TemplateField HeaderText="Title" SortExpression="Title">
      <HeaderTemplate>
                            Title
                    </HeaderTemplate>
                    <ItemTemplate>
                     <asp:Label ID="Title" runat="server" Text='<%# Eval("Title") %>' />
                    </ItemTemplate>
                    <EditItemTemplate>
                     <asp:TextBox ID="editTitle" runat="server" Text='<%# Eval("Title") %>' width="80%" />
                    </EditItemTemplate>
                    <FooterTemplate>
                     <asp:TextBox ID="addTitle" runat="server" width="50%"/>
                    </FooterTemplate>
                    <HeaderStyle CssClass="ms-vb2" />
                    <ItemStyle Width="80%" CssClass="ms-vb2" />
                    <FooterStyle  BackColor="#FFC0C0" CssClass="ms-vb2" />
            </asp:TemplateField>

     

    cs file:
    protected void gv_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
         //First of all e.NewValues.OldValues are always empty and count is always 0

         int rIndex = e.RowIndex;
        
    string title = ((TextBox)gv.Rows[rIndex].FindControl("editTitle")).Text; //this is where it crashes. 
     
     ...

    }

     

     

     

    Graphfixz Data & Web Design
    http://www.graphfixz.com
  • Re: OnRowUpdating

    05-09-2008, 4:11 PM
    • Loading...
    • Graphfixz
    • Joined on 01-10-2003, 11:23 AM
    • Posts 337

    ok, it just got more weird for me. I took out the OnRowUpdating event from the Grid and now when I  hit on Update it doesn't give the error that I should get:

    Something to the nature of: The GridView fired event RowUpdating which wasn't handled.

     I must be missing something here!

    Graphfixz Data & Web Design
    http://www.graphfixz.com
Page 1 of 1 (9 items)