I have a gridview with a delete icon in each row. I have an updatepanel and content template around ita nd the command routine does work to delete the row. BUt i am unable to get theupdate panel to do an asynchronous update.
the HTML:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional" ><Triggers><asp:AsyncPostBackTrigger ControlID="ibdelete" EventName="ibdelete_Command" /></Triggers> <ContentTemplate><asp:GridView ID="gvmain" runat="server" EmptyDataRowStyle-Width="750px" Style="width:
750px; margin: auto; text-align: center;" AutoGenerateColumns="False"
EmptyDataText="No rides logged today! You can be the first!" DataKeyNames="rideid" CssClass="gvmain"><AlternatingRowStyle CssClass="gvaltrow" /><Columns><asp:TemplateField HeaderText="Detail"><ItemTemplate><asp:ImageButton ID="ibDetail" runat="server" ImageUrl="~/Images/Icons/magnifier.png" ToolTip=" Click for Details"
Style="height: 16px" CommandName="Select" CommandArgument='<%# Eval("rideid") %>' OnCommand="ImageButton1_Command" /></ItemTemplate><ItemStyle HorizontalAlign="Center" Width="75px" /></asp:TemplateField><asp:TemplateField HeaderText="Delete"><ItemTemplate><asp:ImageButton ID="ibdelete" runat="server" CommandName="Delete"
ImageUrl="~/Images/Icons/cross.png" ToolTip="Delete this ride!"
CommandArgument='<%# Eval("rideid") %>' OnCommand="ibdelete_Command" /><ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" ConfirmText="Delete this ride?" TargetControlID="ibdelete"/></ItemTemplate><ItemStyle HorizontalAlign="Center" Width="75px" /></asp:TemplateField>
and so on...
This returns a message as soon as the gridview opens --
"System.InvalidOperationException: A control with ID 'ibdelete' could not be found for the trigger in UpdatePanel 'UpdatePanel1'.
So i took the trigger clause out and added to the Delete command code:
protected void ibdelete_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "Delete")
{
int arg = Convert.ToInt32(e.CommandArgument);
stats st = new stats();
st.DeleteRide(arg);
UpdatePanel1.Update();
}
}which executes without error and deletes the row fromthe database, but doesnt refresh the gridview. anyone familiar with this?