I have setup a GridView inside an UpdatePanel. The GridView has a SELECT CommandField that is tied to Gridview1_SelectedIndexChanged method. I would like the GridView to refresh after a row is selected but it never does. I have tried several different scenarios and none seem to work.
- I have set UpdateMode to "Conditional" and "Always" on the UpdatePanel and tried to force an update to the UpdatePanel in the code behind.
- I have converted the CommandField to a templatefield with a button
Here is the sanitized 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>