i'm trying to update my asp.net gridview from a close method of a Growl Message.
the jquery code is:
$.gritter.add({
title: 'Success',
text: msg.d[0],
sticky: true,
after_close: function () {
__doPostBack('UpdatePanel1', '');
}
});
the gridview update panel is:
<div class="module_content">
<asp:Label runat="server" ID="Label1" />
<asp:GridView ID="grd1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Hyperlink href="#" id="getSessionID" class="view-details" runat="server">View details</asp:Hyperlink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Message Id">
<ItemTemplate>
<%# Eval("SessionID") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sender">
<ItemTemplate>
<%# Eval("Sender") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Message Date">
<ItemTemplate>
<asp:HyperLink CssClass="msgDateDate" ID="lnkMsgDateSummary" Text='<%#DateTime.Parse(Eval("MsgDate").ToString()).ToShortDateString()%>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Message Type">
<ItemTemplate>
<asp:HyperLink CssClass="msgDateType" ID="lnkMsgDateType" Text='<%# Eval("MsgType")%>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Reference">
<ItemTemplate>
<%# Eval("MsgRef")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<%# Eval("Status")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
Within the gridview is a hyperlink, which opens up a dialog, the dialog calls a webmethod, which results in the data of the gridview changing.
I use a Growl notification to inform the end user that something has changed, and on click the ok button the after_close function is called.
When I debug the OnLoad=UpdatePanel1_Load is called, and I can see that all that changes are being bound etc.
However, my GridView total vanishes after the after_close method is run, it's not even in the DOM anymore.
Oddly though the label is there!
Can anyone tell me why my Grid vanishes?
*EDIT*
Ok, so i've added the EmptyDataText to the gridview, and the text specified in here is visible. So, even though a call the bindmethod my Gridview is empty!
On your page load event, you need to implement a check when ispostback
is true, then do not load the page to default value i.e. binding of grid view. Hope this helps.