dataprocess.cs using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Web.Mail; using System.Text.RegularExpressions; using System.Data.SqlClient; namespace plane { /// <summary> /// tree_Index μ??aòa?μ?÷?£ /// </summary> public class dataprocess : System.Web.UI.Page {
protected config conn=new config(); string str_Sql; private void Page_Load(object sender, System.EventArgs e) { if (Request.QueryString["mode"]=="area_country"){ string area_id=Request.QueryString["upid"]; str_Sql="select id,country_name from country where area_id="+area_id; conn.ExeSql1(str_Sql); Response.Write("myform.to_country.length=0"); Response.Write(";"); Response.Write("var o=new Option('到达国家','-1')"); Response.Write(";"); Response.Write("myform.to_country.add(o)"); Response.Write(";"); string id; string country_name; while(conn.myReader.Read()) { id=conn.myReader.GetValue(0).ToString().Trim(); country_name=conn.myReader.GetValue(1).ToString().Trim(); Response.Write("var o=new Option('"+country_name+"','"+id+"')"); Response.Write(";"); Response.Write("myform.to_country.add(o)"); Response.Write(";"); } conn.closeReader(); } else if (Request.QueryString["mode"]=="area_city"){ string country_id=Request.QueryString["upid"]; str_Sql="select id,city_name from city where country_id="+country_id; conn.ExeSql1(str_Sql); Response.Write("myform.to_city.length=0"); Response.Write(";"); Response.Write("var o=new Option('到达城市','-1')"); Response.Write(";"); Response.Write("myform.to_city.add(o)"); Response.Write(";"); string id; string city_name; while(conn.myReader.Read()) { id=conn.myReader.GetValue(0).ToString().Trim(); city_name=conn.myReader.GetValue(1).ToString().Trim(); Response.Write("var o=new Option('"+city_name+"','"+id+"')"); Response.Write(";"); Response.Write("myform.to_city.add(o)"); Response.Write(";"); } conn.closeReader(); } } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN£o??μ÷ó?ê? ASP.NET Web ′°ì?éè???÷?ù±?Dèμ??£ // InitializeComponent(); base.OnInit(e); }
{
DataTable dt = GetYourSmallClassByBigClassId(this.bigclass.SelectedValue);
this.smallclass.DataSource = dt;
this.smallclass.DataTextField = ...
...............
this.smallclass.DataBind();
}
brightheroes(闭关|那一剑的风情)
如果,你想做好一点,不刷新页面,可以在客户端加载XML文件。
{
v=document.all.to_area.options[document.all.to_area.selectedIndex].value;
myform.to_city.length=0;
var o=new Option('到达城市','-1');
myform.to_city.add(o);
myform.to_country.length=0;
myform.to_country.disabled=true;
var o=new Option('载入中...','-1');
myform.to_country.add(o);
dataprocess.src="dataprocess.aspx?mode=area_country&upid="+v;
myform.to_country.disabled=false;
}
function country_change(v)
{
v=document.all.to_country.options[document.all.to_country.selectedIndex].value;
myform.to_city.length=0;
myform.to_city.disabled=true;
var o=new Option('载入中...','0');
myform.to_city.add(o); dataprocess.src="dataprocess.aspx?mode=area_city&upid="+v;
myform.to_city.disabled=false;
}
function city_change()
{
v=document.all.to_city.options[document.all.to_city.selectedIndex].text;
document.all.city_text.value=v;
}
</script>
<script language="javascript" id="dataprocess"></script>
<script>
<tr>
<td height="22" class="样式4"> <div align="center">到达大州</div></td>
<td height="22" class="样式4"><span class="forumRow">
<asp:DropDownList ID="to_area" runat="server" OnChanged="area_change(this.value)">
<asp:ListItem Value="-1">到达大州</asp:ListItem>
</asp:DropDownList>
</span></td>
<td class="样式4">到达国家</td>
<td class="样式4"><span class="forumRow">
<asp:DropDownList ID="to_country" runat="server" OnChanged="country_change(this.value)" Width="95" >
<asp:ListItem Value="-1">到达国家</asp:ListItem>
</asp:DropDownList>
</span></td>
<td class="样式4"><span class="forumRow"></span></td>
<td class="样式4">到达城市 </td>
<td class="样式4"><span class="forumRow">
<asp:DropDownList ID="to_city" OnChanged="city_change()" CssClass="select" runat="server">
<asp:ListItem value="-1">选择到达地</asp:ListItem>
</asp:DropDownList>
</span> </td>
</tr>
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
using System.Text.RegularExpressions;
using System.Data.SqlClient;
namespace plane
{
/// <summary>
/// tree_Index μ??aòa?μ?÷?£
/// </summary>
public class dataprocess : System.Web.UI.Page
{
protected config conn=new config();
string str_Sql;
private void Page_Load(object sender, System.EventArgs e)
{
if (Request.QueryString["mode"]=="area_country"){
string area_id=Request.QueryString["upid"];
str_Sql="select id,country_name from country where area_id="+area_id;
conn.ExeSql1(str_Sql);
Response.Write("myform.to_country.length=0");
Response.Write(";");
Response.Write("var o=new Option('到达国家','-1')");
Response.Write(";");
Response.Write("myform.to_country.add(o)");
Response.Write(";");
string id;
string country_name;
while(conn.myReader.Read())
{
id=conn.myReader.GetValue(0).ToString().Trim();
country_name=conn.myReader.GetValue(1).ToString().Trim();
Response.Write("var o=new Option('"+country_name+"','"+id+"')");
Response.Write(";");
Response.Write("myform.to_country.add(o)");
Response.Write(";");
}
conn.closeReader();
}
else if (Request.QueryString["mode"]=="area_city"){
string country_id=Request.QueryString["upid"];
str_Sql="select id,city_name from city where country_id="+country_id;
conn.ExeSql1(str_Sql);
Response.Write("myform.to_city.length=0");
Response.Write(";");
Response.Write("var o=new Option('到达城市','-1')");
Response.Write(";");
Response.Write("myform.to_city.add(o)");
Response.Write(";");
string id;
string city_name;
while(conn.myReader.Read())
{
id=conn.myReader.GetValue(0).ToString().Trim();
city_name=conn.myReader.GetValue(1).ToString().Trim();
Response.Write("var o=new Option('"+city_name+"','"+id+"')");
Response.Write(";");
Response.Write("myform.to_city.add(o)");
Response.Write(";");
}
conn.closeReader();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN£o??μ÷ó?ê? ASP.NET Web ′°ì?éè???÷?ù±?Dèμ??£
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// éè???÷?§3??ùDèμ?·?·¨ - 2?òaê1ó?′ú??±à?-?÷DT??
/// ′?·?·¨μ??úèY?£
/// </summary>
private void InitializeComponent()
{
//this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
{
if(this.DropDownList1.SelectedValue!="")
{
int id = int.Parse(this.DropDownList1.SelectedValue.Trim());
DataSet ds=dm.selectall(id);
this.namebox.Text = ds.Tables[0].Rows[0][0].ToString();
this.comboBox1.SelectedValue = ds.Tables[0].Rows[0][1].ToString();
this.moneybox.Text = ds.Tables[0].Rows[0][2].ToString();
this.cmbox.Text = ds.Tables[0].Rows[0][3].ToString();
}
}