Master/Detail view with FormView, GridView and Update Panels

Last post 09-12-2007 2:25 PM by htorrejo. 3 replies.

Sort Posts:

  • Master/Detail view with FormView, GridView and Update Panels

    10-12-2006, 5:50 PM

    Hi,

    I have a Master/Detail scenario with a form view and a grid view. When a row is selected on the grid view, the form view is populated and its mode changed to "edit" through a custom handler for the SelectedIndexChanging event of the GridView.

    I have wrapped the gridview and the FormView in two update panels. When the GridView row is selected, the GridView's UpdatePanel refreshes OK as does the FormView's UpdatePanel.

    However, when the FormView record is updated, the FormView's UpdatePanel refreshes OK, but the GridView does not refresh/rebind, leaving the row still selected.

    I imagine that I need to alter the triggers - what should they be?

       <atlas:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate> 
            
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                ...
                </asp:GridView>
                
             </ContentTemplate>
             <Triggers>
                
             </Triggers>
      
        </atlas:UpdatePanel>   
                
        <atlas:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                
              <asp:FormView ID="FormView1" DefaultMode="Insert" runat="server" DataKeyNames="ID" DataSourceID="ObjectDataSource2">
              ...
              </asp:FormView>            
    
            </ContentTemplate>    
            <Triggers>
                <atlas:ControlEventTrigger ControlID="FormView1" EventName="ItemInserted" />
                <atlas:ControlEventTrigger ControlID="FormView1" EventName="ItemUpdated" /> 
            </Triggers>
        </atlas:UpdatePanel>
     
  • Re: Master/Detail view with FormView, GridView and Update Panels

    10-13-2006, 3:40 PM
    • Loading...
    • Fredrik N
    • Joined on 06-22-2002, 5:03 AM
    • Sweden
    • Posts 5,333
    • Moderator
      TrustedFriends-MVPs

    One way to do it is to hook up to the ItemUpdated event of the FormView and call the UpdatePanel2's Update method (server-side), make sure the UpdatePanel's mode is set to Conditional

    /Fredrik Normén NSQUARED2
    Microsoft MVP, MCSD, MCAD, MCT

    ASPInsiders
    My Blog, ASP.Net 2.0 etc

    Cornerstone AB
  • Re: Master/Detail view with FormView, GridView and Update Panels

    10-23-2006, 10:49 PM
    • Loading...
    • msbcgsch
    • Joined on 06-23-2003, 9:38 AM
    • Posts 50

    Thanks Fredrik.  I actually did read this and tried it before my original posting, but it wasn't working.  If you look in the code of my original post, I had this (along with DataKeyNames, etc.):

    <SelectParameters>

    <asp:ControlParameter ControlID="GridView1" Name="ClassId" PropertyName="SelectedValue" DefaultValue="2" Type="Int32" />

    <asp:ControlParameter ControlID="GridView1" Name="StartDate" PropertyName="SelectedValue" DefaultValue="10/26/2006" Type="DateTime" />

    <asp:ControlParameter ControlID="GridView1" Name="LocationID" PropertyName="SelectedValue" DefaultValue="1" Type="Int32" />

    </SelectParameters>

     -----------------------------

    It forwards the DefaultValues, but not the values from the GridView SelectedItem row.

    I can't find anything in the tutorial that I'm not doing.  I have three parameters becuase there are three fields that make up the KeyFields in my DB table.

     Thanks again.

    Mark

  • Re: Master/Detail view with FormView, GridView and Update Panels

    09-12-2007, 2:25 PM
    • Loading...
    • htorrejo
    • Joined on 09-12-2007, 2:06 PM
    • Posts 2
    Hi,I was having the same issue and by looking at your original post, I realized that I could use the ItemInserted event for the FormView control. <asp:AsyncPostBackTrigger ControlID="FormView1" EventName="ItemInserted" /> The only thing I had to add to my FormView1 control definition was: OnItemInserted="FormView1_ItemInserted" Also in the code behind the associated code I added was:protected void FormView1_ItemInserted(object sender, ForrmViewInsertedEventArgs e){gridMailList.DataBind();}  Without the DataBind() it does not do the trick. 

    Thanks, Hugo

     

Page 1 of 1 (4 items)
Microsoft Communities
Page view counter