I installed the GridView inside the UpdatePanel. GridView has a SELECT CommandField element bound to the Gridview1_SelectedIndexChanged method. I would like the GridView to be updated after row selection, but this never happens. I tried several different scenarios and no one works.
- I installed UpdateMode in “Conditional” and “Always” on UpdatePanel and tried to force update UpdatePanel in the code.
- I converted CommandField to a template field using a button
Here is the sanitary code:
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" PagerSettings-Visible="true" EnableViewState="False" > <Columns> <asp:CommandField ButtonType="Image" SelectImageUrl="~/images/icon.gif" ShowSelectButton="True" /> <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" /> <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /> </Columns> </asp:GridView> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel>
The data source looks something like this:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DataObjectTypeName="myNamespace.Item" InsertMethod="myInsertMethod" SelectMethod="mySelectMethod" TypeName="myNamespace.ItemMgr" UpdateMethod="myUpdateMethod"> </asp:ObjectDataSource>
source share