如:在A.aspx里有DropDownList,里面是从数据库填充的数据,比如里面有1,2,3...在这个DropDownList右侧(此页面里)有个添加按钮,点“添加”后,弹出一个对话框似的添加页面,如:B.aspx,在该页面添加完信息后点“保存”后关闭添加页面。此时再点A.aspx里的DropDownList时,刚添加的信息在里面显示。请问如何实现?谢谢大家了。
解决方案 »
- 100分请教缓存依赖的问题
- 一个虚拟主机提供并发连接512个,如何理解?
- 我的第一个处女网站,从头到尾一个包办,不足之处,请指教?
- 在自定义控件中用LoadControl加载用户控件,该用户控件的视图状态怎么会失效?
- 怎么为datagrid中前五条记录中的某个值加上"new"这样的标识.
- web应用中用9.0水晶报表专家产生的表格如何水平居中如何发布,不打包的变通办法,可不可以拷贝几个文件
- 请教制作日期文本框输入问题
- forms验证出现的问题
- 一直想知道的:如何调用函数???--waiting!!!
- 。NET 怎样画正玄曲线?
- label如果没有内容则不显示,且不占用页面位置?
- 网页嵌入地图 问题,解决后就给分
<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里】
<%@ 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);
}
}
说下思路~~方式一:在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 再把数据保存回数据库