Results 1 to 2 of 2

Thread: modal popup and and gridview

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    modal popup and and gridview

    i wanted to open modal up using ajax,gridview and detail view but its not opening

    see teh code here
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Configuration;
    using System.Data.SqlClient;
    using System.Data;
    
    
    //http://mattberseth.com/blog/2008/04/masterdetail_with_the_gridview.html
    
    public partial class GRIDVIEW_DetailView : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    
        protected void Customer_Selected(Object sender, GridViewCommandEventArgs e)
        {
    
    
        }
    
    
    
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
    
        }
        protected void gvCustomers_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.dvCustomerDetail.Visible = true;
            ExecuteTSQL ts = new ExecuteTSQL();
            string s = this.gvCustomers.SelectedRow.DataItemIndex.ToString();
            string s1 = this.gvCustomers.SelectedValue.ToString();
    
            DataSet ds = new DataSet();
            ds = ts.SelectQueryDS("select * from orders where customerid=" + "'" + s1 + "'");
            this.dvCustomerDetail.DataSource = ds;
            this.DataBind();
    
    
    
            this.mdlPopup.Show();
    
        }
        protected void gvCustomers_RowCommand(object sender, GridViewCommandEventArgs e)
        {
    
        }
    }

    Code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="GRIDVIEW_DetailView.aspx.cs" Inherits="GRIDVIEW_DetailView" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="head" runat="server">
        <title>Master Details Example</title>
        <script runat="server">
      
        
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnViewDetails_Click(object sender, EventArgs e)
        {
            //  get the gridviewrow from the sender so we can get the datakey we need
            Button btnDetails = sender as Button;
            GridViewRow row = (GridViewRow)btnDetails.NamingContainer;
            
            //  extract the customerid from the row whose details button originated the postback.
            //  grab the customerid and feed it to the customer details datasource
            //  finally, rebind the detailview
            //this.sqldsCustomerDetails.SelectParameters.Clear();
            //this.sqldsCustomerDetails.SelectParameters.Add("customerid", Convert.ToString(this.gvCustomers.DataKeys[row.RowIndex].Value));
            //this.dvCustomerDetail.DataSource = this.sqldsCustomerDetails;
            //this.dvCustomerDetail.DataBind();
    
            ////  update the contents in the detail panel
            //this.updPnlCustomerDetail.Update();
            ////  show the modal popup
            //this.mdlPopup.Show();
        }   
        
        </script>
     
    </head>
    
    <body>
        <form id="form1" runat="server">
         <asp:ToolkitScriptManager ID="toolkitScriptMaster" runat="server">
    </asp:ToolkitScriptManager>
          <div>
                <asp:SqlDataSource ID="sqldsCustomers" runat="server" 
                    
                    SelectCommand="select customerid, companyname, contactname, contacttitle from customers" 
                    ConnectionString="<%$ ConnectionStrings:renaConnectionString %>" />
                
               <%-- <p style="background-color:AliceBlue; width:95%">
                    Example of using a ModalPopupExtender to edit the indivdual rows of a GridView.<br />
                    To test out the functionality, click the Details button of any of the rows and watch what happens.<br />
                </p>--%>
                
                <br />
                <asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>            
                        <asp:Label ID="lblTitle" runat="server" Text="Customers" BackColor="lightblue" Width="95%" />
                        <asp:GridView 
                            ID="gvCustomers" runat="server" DataKeyNames="customerid" AutoGenerateColumns="False" 
                            AllowPaging="True" AllowSorting="True" DataSourceID="sqldsCustomers" 
                            Width="95%" onselectedindexchanged="gvCustomers_SelectedIndexChanged" 
                            onrowcommand="gvCustomers_RowCommand">
                            <AlternatingRowStyle BackColor="aliceBlue" />
                            <HeaderStyle HorizontalAlign="Left" />
                            <Columns>
                                <asp:BoundField DataField="customerid" HeaderText="customerid" 
                                    SortExpression="customerid" ReadOnly="true" />
                                <asp:BoundField DataField="companyname" HeaderText="companyname" 
                                    SortExpression="companyname" />
                                <asp:BoundField DataField="contactname" HeaderText="contactname" 
                                    SortExpression="contactname" />
                                <asp:BoundField DataField="contacttitle" HeaderText="contacttitle" 
                                    SortExpression="contacttitle" />     
                                    <asp:TemplateField>
                                    <ItemTemplate>
                                    <asp:LinkButton id=btnviewdetails runat=server CommandArgument=customerid Text=edit CommandName=select>
                                    </asp:LinkButton>
                                    </ItemTemplate>
                                    
                                    </asp:TemplateField>           
                            </Columns>                    
                        </asp:GridView>
                    </ContentTemplate>
                </asp:UpdatePanel>                    
                
         <%--             --%>     
                <asp:Panel ID="pnlPopup" runat="server" Width="500px" style="display:none">
                    <asp:UpdatePanel ID="updPnlCustomerDetail" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                           <asp:Button id="btnShowPopup" runat="server" style="display:none" />
                <asp:ModalPopupExtender 
                    ID="mdlPopup" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlPopup" 
                    CancelControlID="btnClose" />
                     <asp:DetailsView Visible=false ID="dvCustomerDetail" runat="server" DefaultMode="Edit" Width="95%" BackColor="white">
                      
                       </asp:DetailsView> 
                       
                    <asp:LinkButton id=btnclose CausesValidation=false runat=server>
                    
                    
                    </asp:LinkButton>
                    </ContentTemplate>
                    </asp:UpdatePanel>
                    </asp:Panel>
              
                     
            </div>
    
        </form>
    </body>
    </html>
    please do let me know if need further description of problem
    There is no achievement without goals

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: modal popup and and gridview

    Hello,

    You might want to take a look at this sample:

    http://www.asp.net/ajax/tutorials/la...server-code-cs

    Hope that helps!

    Gary

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width