Reputation: 684
i just want to add grid view to update panel for fast Sorting and Pagging Request has been made. and my grid view works fine. here i just want to add one trigger like one link button but it's gives me run time Error like :
A control with ID 'lbut_category' i set as AsyncPostBackTrigger
here is my design view :
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GV_ViewCategories" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
GridLines="None" Width="100%"
ondatabound="GV_ViewCategories_DataBound"
onpageindexchanging="GV_ViewCategories_PageIndexChanging"
onprerender="GV_ViewCategories_PreRender"
onrowcommand="GV_ViewCategories_RowCommand"
onrowdatabound="GV_ViewCategories_RowDataBound"
onsorting="GV_ViewCategories_Sorting" DataKeyNames="Id">
<RowStyle CssClass="grid1" HorizontalAlign="Left" />
<Columns>
<asp:TemplateField>
<HeaderStyle CssClass="headinglist_bg" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Category Name" SortExpression="CategoryName">
<HeaderStyle CssClass="headinglist_bg" />
<ItemTemplate>
<asp:LinkButton ID="lbut_category" runat="server"
CommandArgument='<%# Eval("Id") %>' CommandName="View"
Text='<%# Bind("CategoryName") %>'></asp:LinkButton>
</ItemTemplate>
<HeaderTemplate>
<asp:LinkButton ID="lbut_sortname" runat="server"
CommandArgument="CategoryName" CommandName="Sort" CssClass="normaltext"
Font-Bold="true" Text="Category Name"></asp:LinkButton>
<asp:PlaceHolder ID="placeholdercategory" runat="server"></asp:PlaceHolder>
</HeaderTemplate>
<ItemStyle CssClass="quicklink" />
</asp:TemplateField>
</Columns>
<EmptyDataRowStyle BorderWidth="0px" Width="0px" />
<EmptyDataTemplate>
<asp:Label ID="Label2" runat="server" ForeColor="Red"
Text="No Records are found"></asp:Label>
</EmptyDataTemplate>
<PagerStyle CssClass="pager" HorizontalAlign="Center" VerticalAlign="Middle" />
<PagerTemplate>
<table>
<tr>
<td>
<asp:ImageButton ID="ImageButton1" runat="server"
AlternateText="Go to First Page" CommandArgument="First" CommandName="Page"
ImageUrl="../images/1330128819_resultset_first.png" />
</td>
<td>
<asp:ImageButton ID="ImageButton2" runat="server" AlternateText="Previous Page"
CommandArgument="Prev" CommandName="Page"
ImageUrl="../images/1330128981_resultset_previous.png" />
</td>
<td>
Page <asp:DropDownList ID="ddlPages" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="ddlPages_SelectedIndexChanged">
</asp:DropDownList>
of
<asp:Label ID="lblPageCount" runat="server"></asp:Label>
</td>
<td>
<asp:ImageButton ID="ImageButton3" runat="server" AlternateText="Next Page"
CommandArgument="Next" CommandName="Page"
ImageUrl="../images/Farm-Fresh_resultset_next.png" />
</td>
<td>
<asp:ImageButton ID="ImageButton4" runat="server"
AlternateText="Go to Last Page" CommandArgument="Last" CommandName="Page"
ImageUrl="../images/1330128876_resultset_last.png" />
</td>
</tr>
</table>
</PagerTemplate>
<FooterStyle CssClass="pager" VerticalAlign="Bottom" />
<HeaderStyle HorizontalAlign="Left" />
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GV_ViewCategories"
EventName="RowCommand" />
</Triggers>
</asp:UpdatePanel>
and for resolving Invalid Callback and Post Back argument i set EnableEventValidation="false"
but here i have to double click on Link Button then it's respond.
and here EnableEventValidation="false"
it's may be dangerous for security purpose.
can any body have solution for that ??
Upvotes: 0
Views: 155
Reputation: 46
Setting ChildrenAsTriggers="true" will suffice for triggering a postback for the updatepanel. You don't need to add the PostBackTrigger in this case. lbut_sort_person_name can't be found because it's in a different naming container namely a row of the gridview control.
Upvotes: 1