locked
DetailsView in ModalPopup RRS feed

  • Question

  • User-971051533 posted

    Hi.  I have a GridView that when you click the edit button it loads a DetailsVIew in Edit Mode inside of a ModalPopup.  It works fine the first time you click edit.  If you click edit again to make changes to a second record it loads but the DetailsView is not in the ModalPopup.  Can anyone tell me what I"m doing wrong?  My code is below.

    this is my source code with the GridVIew and DetailsVIew:

     <asp:SqlDataSource ID="sdsMembers" runat="server" 
            ConnectionString="<%$ ConnectionStrings:DoseRec_ABTConnectionString %>"
            
            SelectCommand="SELECT [intMemberID], [vcharTitle], [vcharFirstName], [vcharLastName], [vcharSuffix], [vcharJobTitle], [vcharAddress1], [vcharAddress2], [vcharCity], [vcharState], [vcharZipCode], [vcharPhone], [vcharFax], [bitActive] FROM [tbl_Members]" 
            DeleteCommand="DELETE FROM [tbl_Members] WHERE [intMemberID] = @intMemberID" 
            InsertCommand="INSERT INTO [tbl_Members] ([vcharTitle], [vcharFirstName], [vcharLastName], [vcharSuffix], [vcharJobTitle], [vcharAddress1], [vcharAddress2], [vcharCity], [vcharState], [vcharZipCode], [vcharPhone], [vcharFax], [bitActive]) VALUES (@vcharTitle, @vcharFirstName, @vcharLastName, @vcharSuffix, @vcharJobTitle, @vcharAddress1, @vcharAddress2, @vcharCity, @vcharState, @vcharZipCode, @vcharPhone, @vcharFax, @bitActive)" 
            UpdateCommand="UPDATE [tbl_Members] SET [vcharTitle] = @vcharTitle, [vcharFirstName] = @vcharFirstName, [vcharLastName] = @vcharLastName, [vcharSuffix] = @vcharSuffix, [vcharJobTitle] = @vcharJobTitle, [vcharAddress1] = @vcharAddress1, [vcharAddress2] = @vcharAddress2, [vcharCity] = @vcharCity, [vcharState] = @vcharState, [vcharZipCode] = @vcharZipCode, [vcharPhone] = @vcharPhone, [vcharFax] = @vcharFax, [bitActive] = @bitActive WHERE [intMemberID] = @intMemberID">
            <DeleteParameters>
                <asp:Parameter Name="intMemberID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="vcharTitle" Type="String" />
                <asp:Parameter Name="vcharFirstName" Type="String" />
                <asp:Parameter Name="vcharLastName" Type="String" />
                <asp:Parameter Name="vcharSuffix" Type="String" />
                <asp:Parameter Name="vcharJobTitle" Type="String" />
                <asp:Parameter Name="vcharAddress1" Type="String" />
                <asp:Parameter Name="vcharAddress2" Type="String" />
                <asp:Parameter Name="vcharCity" Type="String" />
                <asp:Parameter Name="vcharState" Type="String" />
                <asp:Parameter Name="vcharZipCode" Type="String" />
                <asp:Parameter Name="vcharPhone" Type="String" />
                <asp:Parameter Name="vcharFax" Type="String" />
                <asp:Parameter Name="bitActive" Type="Boolean" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="vcharTitle" Type="String" />
                <asp:Parameter Name="vcharFirstName" Type="String" />
                <asp:Parameter Name="vcharLastName" Type="String" />
                <asp:Parameter Name="vcharSuffix" Type="String" />
                <asp:Parameter Name="vcharJobTitle" Type="String" />
                <asp:Parameter Name="vcharAddress1" Type="String" />
                <asp:Parameter Name="vcharAddress2" Type="String" />
                <asp:Parameter Name="vcharCity" Type="String" />
                <asp:Parameter Name="vcharState" Type="String" />
                <asp:Parameter Name="vcharZipCode" Type="String" />
                <asp:Parameter Name="vcharPhone" Type="String" />
                <asp:Parameter Name="vcharFax" Type="String" />
                <asp:Parameter Name="bitActive" Type="Boolean" />
                <asp:Parameter Name="intMemberID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource> 
           
    
        </p>
        <p> 
           
    
            <asp:SqlDataSource ID="sdsMembersDetail" runat="server" 
                ConnectionString="<%$ ConnectionStrings:DoseRec_ABTConnectionString %>"
                
                SelectCommand="SELECT [intMemberID] AS ID, [vcharTitle] AS Title, [vcharFirstName] AS 'First Name', [vcharLastName] AS 'Last Name', [vcharSuffix] AS Suffix, [vcharJobTitle] AS 'Job Title', [vcharAddress1] AS Address1, [vcharAddress2] AS Address2, [vcharCity] AS City, [vcharState] AS State, [vcharZipCode] AS 'Zip Code', [vcharPhone] AS Phone, [vcharFax] AS Fax, [bitActive] AS Active FROM [tbl_Members] WHERE ([intMemberID] = @intMemberID)">
                <SelectParameters>
                    <asp:QueryStringParameter DefaultValue="" Name="intMemberID" 
                        QueryStringField="intMemberID" Type="Int32" />
                </SelectParameters>
            </asp:SqlDataSource>
     
       
           
    
        </p>
        <p>
            &nbsp;<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>          
                <asp:GridView ID="gvMembers" runat="server" AutoGenerateColumns="False" 
                    DataKeyNames="intMemberID" DataSourceID="sdsMembers" style="background-color:White;">
                    <Columns>
                        <asp:CommandField ShowDeleteButton="True" />
                         <asp:TemplateField ControlStyle-Width="50px" HeaderStyle-Width="60px">
                                    <ItemTemplate>                                    
                                        <asp:LinkButton ID="btnViewDetails" runat="server" OnClick="BtnViewDetails_Click">Edit</asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                        <asp:BoundField DataField="intMemberID" HeaderText="ID" 
                            InsertVisible="False" ReadOnly="True" SortExpression="intMemberID" />
                        <asp:BoundField DataField="vcharTitle" HeaderText="vcharTitle" 
                            SortExpression="vcharTitle" />
                        <asp:BoundField DataField="vcharFirstName" HeaderText="First Name" 
                            SortExpression="vcharFirstName" />
                        <asp:BoundField DataField="vcharLastName" HeaderText="Last Name" 
                            SortExpression="vcharLastName" />
                        <asp:BoundField DataField="vcharSuffix" HeaderText="Suffix" 
                            SortExpression="vcharSuffix" />
                        <asp:BoundField DataField="vcharJobTitle" HeaderText="Job Title" 
                            SortExpression="vcharJobTitle" />
                        <asp:BoundField DataField="vcharAddress1" HeaderText="Address1" 
                            SortExpression="vcharAddress1" />
                        <asp:BoundField DataField="vcharAddress2" HeaderText="Address2" 
                            SortExpression="vcharAddress2" />
                        <asp:BoundField DataField="vcharCity" HeaderText="City" 
                            SortExpression="vcharCity" />
                        <asp:BoundField DataField="vcharState" HeaderText="State" 
                            SortExpression="vcharState" />
                        <asp:BoundField DataField="vcharZipCode" HeaderText="Zip Code" 
                            SortExpression="vcharZipCode" />
                        <asp:BoundField DataField="vcharPhone" HeaderText="Phone" 
                            SortExpression="vcharPhone" />
                        <asp:BoundField DataField="vcharFax" HeaderText="Fax" 
                            SortExpression="vcharFax" />
                        <asp:CheckBoxField DataField="bitActive" HeaderText="Active" 
                            SortExpression="bitActive" />
                    </Columns>
                </asp:GridView>  
            </ContentTemplate>
            </asp:UpdatePanel>
            <asp:Button id="btnShowPopup" runat="server" style="display:none" />
             <ajaxToolKit:ModalPopupExtender 
                    ID="mdlPopup" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlPopup" 
                    CancelControlID="btnClose" BackgroundCssClass="modalBackground" />
                <asp:Panel ID="pnlPopup" runat="server" Width="500px" style="display:none">
                    <asp:UpdatePanel ID="updPnlCustomerDetail" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:Label ID="lblMemberDetail" runat="server" Text="Member Detail" BackColor="lightblue" Width="95%" />
                            <asp:DetailsView ID="dvMemberDetail" runat="server" DefaultMode="Edit" Width="95%" BackColor="white" OnItemUpdating="dvMembersDetail_ItemUpdating">                        
                            </asp:DetailsView>
                        </ContentTemplate>                
                    </asp:UpdatePanel>
                    <div align="right" style="width:95%">
                        <asp:LinkButton 
                            ID="btnSave" runat="server" Text="Save"                         
                            Width="50px" onclick="btnSave_Click" />
                         <asp:LinkButton ID="btnClose" runat="server">Close</asp:LinkButton>
                    </div>                     
          
                </asp:Panel>
           

    Here's the code behind for the Edit button:

    protected void BtnViewDetails_Click(object sender, EventArgs e)
            {
                LinkButton btnDetails = sender as LinkButton;
                GridViewRow row = (GridViewRow)btnDetails.NamingContainer;
                this.sdsMembersDetail.SelectParameters.Clear();
                this.sdsMembersDetail.SelectParameters.Add("intMemberID", Convert.ToString(this.gvMembers.DataKeys[row.RowIndex].Value));
                this.dvMemberDetail.DataSource = this.sdsMembersDetail;
                this.dvMemberDetail.DataBind();
                this.updPnlCustomerDetail.Update();
                this.mdlPopup.Show();
            }
    

    If any other code is needed like the code for my save button please let me know.  Thanks.

    Wednesday, September 18, 2013 9:40 AM

All replies

  • User-971051533 posted

    Nevermind.  Figured it out.

    Wednesday, September 18, 2013 11:41 AM