Newbie help please...
I have a grid view within a multiview panel, with View and Delete buttons added in template form. In the code-behind I capture the Delete button successfully and am able to delete the record successfully, but the databind to refresh the grid brings up the EmptyDataText message unless I refresh the page entirely! Can anyone give me a pointer??
Thanks! Marty
Form code looks like this:
<%@ Control Language="vb" Inherits="CCO.Modules.CCOMemberships.ViewCCOMemberships"
CodeFile="ViewCCOMemberships.ascx.vb" AutoEventWireup="false" Explicit="True" %>
<%@ Register TagPrefix="dnn" TagName="Audit" Src="~/controls/ModuleAuditControl.ascx" %>
<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %>
<asp:ObjectDataSource ID="MembershipObjectDataSource" runat="server" DataObjectTypeName="CCO.Modules.CCOMemberships.CCOMembershipsInfo"
DeleteMethod="DeleteMembership" InsertMethod="AddMembership" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetMemberships" TypeName="CCO.Modules.CCOMemberships.CCOMembershipsController"
UpdateMethod="UpdateMembership" OnInit="Page_Load">
<SelectParameters>
<asp:Parameter DefaultValue="00" Name="ModuleId" Type="Int32" />
<asp:Parameter DefaultValue="00" Name="ClubID" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<center>
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="ShowMemberships" runat="server">
<center>
<dnn:Label ID="lblAddMessage" runat="server" ControlName="lblAddMessage" Suffix=":">
</dnn:Label>
</center>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" EmptyDataText="There are no memberships in this Club yet."
HorizontalAlign="Center">
<Columns>
<asp:TemplateField AccessibleHeaderText="Edit" HeaderText="View" ShowHeader="False">
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" CausesValidation="false" CommandArgument='<%# Eval("MembershipID") %>'
CommandName="Edit_Click" ImageUrl="~/images/view.gif" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField AccessibleHeaderText="Delete" HeaderText="Delete" ShowHeader="False">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="false" CommandArgument='<%# Eval("MembershipID") %>'
CommandName="Delete_Click" OnClientClick="return confirm('Are you sure you want to delete this membership?');" ImageUrl="~/images/delete.gif" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" ReadOnly="True">
<ItemStyle HorizontalAlign="Left" Width="250px" />
</asp:BoundField>
</Columns>
</asp:GridView>
<br />
<center>
<asp:Button ID="AddButton" runat="server" Text="Add Membership" />
</center>
</asp:View>
<asp:View ID="View1" runat="server">
</asp:View>
</asp:MultiView>
</center>
And the code behind looks like this:
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
If e.CommandName.CompareTo("Edit_Click") = 0 OrElse e.CommandName.CompareTo("Delete_Click") = 0 Then
If e.CommandName.CompareTo("Delete_Click") = 0 Then
Dim congID As Integer = Me.UserInfo.Profile.GetPropertyValue("ClubID")
Dim memctl As New CCOMembershipsController
memctl.DeleteMembers(ModuleId, e.CommandArgument, Me.UserInfo.Profile.GetPropertyValue("ClubID"), Me.UserId)
memctl.DeleteMembership(ModuleId, e.CommandArgument, Me.UserInfo.Profile.GetPropertyValue("ClubID"), Me.UserId)
GridView1.DataBind()
End If
End If
End Sub
Any ideas??