I have a GridView which is continually rebound using a timer and is within an updatePanel so the page doesn't refresh continually (each row has a countdown sequence so the gridview needs to continually get updated)
Inside the gridview i have an imagebutton with an OnClick method. Previously to get the OnClick method to fire I would make sure the gridView wasn't in an UpdatePanel and that the pageload databinding of the gridview was in an "If Not IsPostBack".
With the Timer though i can't have the gridview binding an an "If Not IsPostBack" and it needs to be in an UpdatePanel.
Is there a way to use an UpdatePanel and "If Not IsPostBack" and still get the OnClick method to be called?
Thanks
Here's some of the code, if my explanation didn't make complete sense:
UpdatePanel/Timer/GridView
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Timer ID="timerCountDown" runat="server" Interval="1000" OnTick="timerCountDown_Tick"></asp:Timer>
<asp:GridView ID="gridBuildQueue" runat="server" AutoGenerateColumns="False"
GridLines="none" ShowFooter="false" ShowHeader="false" Width="100%">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton runat="server" ID="cmdCancelBuild" ImageUrl="~/images/cancel.jpg" OnClick="ImageButton_Click"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
OnTick timer method:
Protected Sub timerCountdown_Tick(ByVal sender As Object, ByVal e As EventArgs)
Me.gridBuildQueue.DataBind()
End Sub
ImageButton_Click method (which is currently never called):
Protected Sub ImageButton_Click(ByVal sender As Object, ByVal e As ImageClickEventArgs)
Dim imageButton As ImageButton = CType(sender, ImageButton)
Dim row As GridViewRow = CType(imageButton.NamingContainer, GridViewRow)
Dim button As ImageButton = DirectCast(row.FindControl("cmdCancelBuild"), ImageButton)
etc...
End Sub