I have 2 user controls on my page. One is used for searching, and the other is used for editing (along with several other things).
A user control that provides a search function uses a GridView to display search results. This GridView has a CommandField used for editing (showEditButton = "true").
I would like to put the GridView in the UpdatePanel so that the paging through the search results is smooth.
The fact is that when a user clicks on the “Edit Link” link (CommandField), I need to pre-generate a full page postback so that the user search control can be hidden and the user edit control can be displayed.
Edit: The reason I need to post back over a full page is because the custom edit control is outside of the UpdatePanel where my GridView is located. It is located not only outside of UpdatePanel, but also in a completely different user management.
I have no idea how to add a CommandField to a full-text callback for UpdatePanel. PostBackTrigger (which is used to indicate that controls cause a full page postback) takes a ControlID as a parameter; however, CommandButton does not have an identifier ... and you can understand why I have a problem with this.
Updating what else I was trying to solve the problem:
I took a new approach to solving the problem.
In my new approach, I used TemplateField instead of CommandField. I put the LinkButton control in the TemplateField and gave it a name. During the GridView RowDataBound event, I received a LinkButton control and added it to UpdatePanel triggers.
This is ASP Markup for UpdatePanel and GridView
<asp:UpdatePanel ID="SearchResultsUpdateSection" runat="server">
<ContentTemplate>
<asp:GridView ID="SearchResultsGrid" runat="server"
AllowPaging="true"
AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="Edit" runat="server" Text="Edit"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField ......
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
VB.NET. , GridView RowDataBound. LinkButton , PostBackTrigger LinkButton UpdatePanel. , PostBackTrigger "" LinkButton GridView Edit:, PostBackTrigger "edit" LinkButton, LinkButtons GridView.
Private Sub SearchResultsGrid_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles SearchResultsGrod.RowDataBound
If e.Row.RowType = DataControlRowType.Header Then
''I am doing stuff here that does not pertain to the problem
Else
Dim editLink As LinkButton = CType(e.Row.FindControl("Edit"), LinkButton)
If editLink IsNot Nothing Then
Dim fullPageTrigger As New PostBackTrigger
fullPageTrigger.ControlID = editLink.ID
SearchResultsUpdateSection.Triggers.Add(fullPageTrigger)
End If
End If
End Sub
, GridView RowEditing , RowCommand.
Private Sub SearchResultsGrid_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles SearchResultsGrid.RowCommand
RaiseEvent EditRecord(Me, New EventArgs())
End Sub
, LinkButtons GridView .
MSDN UpdatePanel.Triggers Property , . , , VB, .
.
,
-Frinny