如:在A.aspx里有DropDownList,里面是从数据库填充的数据,比如里面有1,2,3...在这个DropDownList右侧(此页面里)有个添加按钮,点“添加”后,弹出一个对话框似的添加页面,如:B.aspx,在该页面添加完信息后点“保存”后关闭添加页面。此时再点A.aspx里的DropDownList时,刚添加的信息在里面显示。请问如何实现?谢谢大家了。

解决方案 »

  1.   

    写一个弹出的窗体
         <script language="javascript" type="text/javascript">
        
           var wldwsel
           function SelectHydd(hysmc) {
            oField2 = hysmc;// 返回值
            oField2price =''       
            if(!wldwsel||wldwsel.closed)
              window.open("B.aspx", "wldwsel",  "status=yes,left="+( screen.width - screen.width * .5) /2.5+",top="+( screen.height -screen.height * .5)/2.5+",width=" + screen.width * .7 + ",height=" + screen.height * .6);  
            else
               wldwsel.focus();
            }
        </script>//这个是A页面的 按钮 点击后调用上面的script 弹出一个窗体 事先做好的B.aspx
    <asp:TextBox ID="CUSTOMERNO" runat="server"></asp:TextBox>
     <input id="Button8" type="button" value="button" onclick="SelectHydd('<%=CUSTOMERNO.ClientID%>')"  /><br />利用控件id传参数过来接下来的事情就是在A页面里增加了【可写在script里】
      

  2.   

    b页面直接更新数据库关闭b页面的时候,简单刷新一下A页面,从数据库重新读一下不就好了
      

  3.   

    2楼正解.window.parent.location.reload();self.close();
      

  4.   

    jjl_sky 添加成功了,但这个页面没关闭,还有DropDownList这怎么让他添完就刷新呢?A.aspx那个页面的添加按钮是HTML按钮重新绑不了。<%=CUSTOMERNO.ClientID%> 这个参数的ID好象没用,他们之间不传参。
      

  5.   

    第一个页面
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="t1.aspx.cs" Inherits="t1" %><!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 runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        </div>
        <asp:DropDownList ID="DropDownList1" runat="server">
            <asp:ListItem>1</asp:ListItem>
            <asp:ListItem>2</asp:ListItem>
            <asp:ListItem>3</asp:ListItem>
        </asp:DropDownList>
        <asp:Button ID="Button1" runat="server" Text="Button" PostBackUrl="~/t2.aspx"/>
        </form>
    </body>
    </html>第一个页面 CSusing System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;public partial class t1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["TextBox1"] != null)
            {
                if (Request.QueryString["TextBox1"].ToString() != string.Empty)
                {
                    this.DropDownList1.Items.Add(Request.QueryString["TextBox1"]);
                }
            }
            
        }
    }第2个页面
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="t2.aspx.cs" Inherits="t2" %><!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 runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        </div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1"
            runat="server" Text="Button"  
            onclick="Button1_Click"/>
        </form>
    </body>
    </html>第2个页面 CS
    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;public partial class t2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {    }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/t1.aspx?TextBox1=" + this.TextBox1.Text);    
        }
    }
      

  6.   

    就是在B页面找到某个值 添加进A的下拉里面吧~~简单~~有很多种方法~~代码我就不给你写了~~
    说下思路~~方式一:在B页面把这个字段的值保存回数据库~~B页面关闭~
    再刷新A页面~~方式2  在B页面把数据传给A页面~~在A页面的下拉里面添加起~~然后在A页面再保存回数据库~~这种方式 你可以建立一个中间传送的类~~lei 
    在这个类中申明一个属性~~
    internal static string a;这里不用静态的也可以  但是调用的时候要NEW一下在B页面给与在这个 a  赋值;然后自己关闭
    lei.a="aaa";在A页面中调用这个值lei.a;  就会得到这个值然后
    下拉.items.add(a);就OK  再把数据保存回数据库
      

  7.   

    关闭我又添加了按钮 windows.close()做了```现在就剩刷新了。。