I have an UpdatePanel (named "UpdatePanel1") that contains a Formview. The Formview contains several cascading webdropdown controls and an update button. The update button calls a method that references fields/controls in the Formview.
Outside of the UpdatePanel, I have a Gridview and other buttons that allow the user to delete rows, check all rows, uncheck all rows, etc. in the Gridview. The good thing about the UpdatePanel is that it only does a partial page refresh when
the user picks values from the webdropdown controls. This is desired behavior. After the update button is clicked the logic properly updates the records in the database, the processed records are deleted from the cached table (which is used as the datasource
for the Gridview), and the Gridview is rebound, but the problem is that the page is not getting reloaded/refreshed to display the updated Gridview! I think that I possibly have a markup issue, but I don't know what approach I need to take to accomplish both
tasks: 1.) prevent a full page refresh each time a user selects a value from the webdropdown in the Formview, and 2.) perform a page refresh so that the Gridview object displays the proper results - showing rows that represent the newly bound data source
(i.e., minus the rows that were updated).
hi try like this, place the gridview in another UpdatePanel and in FormView1_ItemUpdated event data bind the GridView and Update the UpdatePanel2 as show in code below
ChrisPalko
Member
68 Points
65 Posts
Need Gridview to postback when click Formview update button in UpdatePanel
Apr 23, 2012 09:35 PM|LINK
I have an UpdatePanel (named "UpdatePanel1") that contains a Formview. The Formview contains several cascading webdropdown controls and an update button. The update button calls a method that references fields/controls in the Formview. Outside of the UpdatePanel, I have a Gridview and other buttons that allow the user to delete rows, check all rows, uncheck all rows, etc. in the Gridview. The good thing about the UpdatePanel is that it only does a partial page refresh when the user picks values from the webdropdown controls. This is desired behavior. After the update button is clicked the logic properly updates the records in the database, the processed records are deleted from the cached table (which is used as the datasource for the Gridview), and the Gridview is rebound, but the problem is that the page is not getting reloaded/refreshed to display the updated Gridview! I think that I possibly have a markup issue, but I don't know what approach I need to take to accomplish both tasks: 1.) prevent a full page refresh each time a user selects a value from the webdropdown in the Formview, and 2.) perform a page refresh so that the Gridview object displays the proper results - showing rows that represent the newly bound data source (i.e., minus the rows that were updated).
This is the markup on my page:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" AsyncPostBackTimeout="120">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:FormView ID="FormView1" runat="server" DataKeyNames="folder_id,matter_nbr,dept_cd"
Width="95%" DataSourceID="FormView1DataSource" Visible="true" DefaultMode="Edit"
OnItemUpdated="FormView1_ItemUpdated"
OnPreRender="FormView1_OnPreRender"
OnDataBound="FormView1_OnDataBound" >
<EditItemTemplate>
<table>
[my formview columns are here]...
<asp:Button ID="UpdateButton" runat="server" CausesValidation="True" Text="Update"
Font-Bold="true" Width="125" Height="30" OnClientClick="return ConfirmGlobalUpdate();"
OnClick="FormView1_OnItemUpdating" />
</table>
</EditItemTemplate>
</asp:FormView>
<asp:HiddenField ID="hdnGlobalUpdate" runat="server" value="" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Panel runat="server" Width="95%" Height="200px" ScrollBars="Vertical">
<asp:GridView [rest of gridview markup here, listing columns, etc.]
</asp:GridView>
</asp:Panel>
Thank you,
Chris
2pac
Participant
1586 Points
269 Posts
Re: Need Gridview to postback when click Formview update button in UpdatePanel
Apr 24, 2012 02:27 AM|LINK
hi try like this, place the gridview in another UpdatePanel and in FormView1_ItemUpdated event data bind the GridView and Update the UpdatePanel2 as show in code below
<asp:Panel ID="Panel1" runat="server" Width="95%" Height="200px" ScrollBars="Vertical"> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:GridView [rest of gridview markup here, listing columns, etc.] </asp:GridView> </ContentTemplate> </asp:UpdatePanel> </asp:Panel>protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e) { GridView1.DataBind(); UpdatePanel2.Update(); }Note: To update the UpdatePanel programtically you need to set UpdateMode="Conditional" for an UpdatePanel
Regards,
Jayesh