N 个 ASP.net DropDownList 无刷新联动菜单 [转]

None.gif 以下代码绝对可以使用,也可以实现多级菜单。。。。
None.gif
None.gif  
< script language = " javascript " >
None.gif   function load(state)
ExpandedBlockStart.gifContractedBlock.gif   
dot.gif {
InBlock.gif    var drp2 
= document.getElementById("DropDownList2");
InBlock.gif    
for(var i=0;i<=drp2.options.length-1;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     drp2.remove(i);
ExpandedSubBlockEnd.gif    }

InBlock.gif    var oHttpReq 
= new ActiveXObject("MSXML2.XMLHTTP");    //发送请求
InBlock.gif
    var oDoc = new ActiveXObject("MSXML2.DOMDocument");    //响应结果
InBlock.gif
    var state=document.getElementById("DropDownList1").value;
InBlock.gif    oHttpReq.open(
"post","webform2.aspx?state="+state, false);
InBlock.gif    oHttpReq.send(
"");
InBlock.gif    result 
= oHttpReq.responseText;
InBlock.gif    oDoc.loadXML(result); 
InBlock.gif    
InBlock.gif   
// items = oDoc.selectNodes("//CITY/Table");
InBlock.gif
       items = oDoc.selectNodes("//address/Table");
InBlock.gif     
for (var item = items.nextNode();item;item = items.nextNode())
ExpandedSubBlockStart.gifContractedSubBlock.gif     
dot.gif{ 
InBlock.gif      var city 
= item.selectSingleNode("//address").nodeTypedValue;
InBlock.gif      var newOption 
= document.createElement("OPTION"); 
InBlock.gif      newOption.text 
= city; 
InBlock.gif      newOption.value 
= city; 
InBlock.gif      drp2.options.add(newOption); 
ExpandedSubBlockEnd.gif      }
 
ExpandedBlockEnd.gif   }

None.gif  
</ script >
None.gif
None.gif 
None.gif
None.gif 
None.gif
None.gif
============================
None.gif
None.gifwebform1.aspx
None.gif
None.gif
private   void  Page_Load( object  sender, System.EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif  
dot.gif {
InBlock.gif   
// 在此处放置用户代码以初始化页面
InBlock.gif
   if(!IsPostBack)
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    SqlConnection con 
= new SqlConnection("packet size=4096;user id=sa;data source=SERVER;persist security info=False;initial catalog=pubs");
InBlock.gif    SqlDataAdapter da 
= new SqlDataAdapter("select state from authors group by state",con);
InBlock.gif    DataSet ds 
= new DataSet("State");
InBlock.gif    da.Fill(ds);
InBlock.gif    
this.DropDownList1.DataSource = ds.Tables[0];
InBlock.gif    
this.DropDownList1.DataTextField = "state";
InBlock.gif    
this.DropDownList1.DataValueField = "state"; 
InBlock.gif    
this.DropDownList1.DataBind();  
InBlock.gif    
this.DropDownList1.Attributes.Add("onchange","load()");  
InBlock.gif    
//DropDownList1.
ExpandedSubBlockEnd.gif
   }

InBlock.gif  
ExpandedBlockEnd.gif  }

None.gif
None.gif 
None.gif
None.gifwebform2.aspx
None.gif
None.gif 
private   void  Page_Load( object  sender, System.EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif  
dot.gif {
InBlock.gif   
// 在此处放置用户代码以初始化页面
InBlock.gif
   if(this.Request["state"]!=null)
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{  
InBlock.gif    
string state = this.Request["state"].ToString();  
InBlock.gif    SqlConnection con 
= new SqlConnection("packet size=4096;user id=sa;data source=SERVER;persist security info=False;initial catalog=pubs");
InBlock.gif    SqlDataAdapter da 
= new SqlDataAdapter("select address from authors where state = '"+state+"'",con);  
InBlock.gif    DataSet ds 
= new DataSet("address");  
InBlock.gif    da.Fill(ds);  
InBlock.gif    XmlTextWriter writer 
= new XmlTextWriter(Response.OutputStream, Response.ContentEncoding);  
InBlock.gif    writer.Formatting 
= Formatting.Indented;  
InBlock.gif    writer.Indentation 
= 4;  
InBlock.gif    writer.IndentChar 
= ' ';  
InBlock.gif    ds.WriteXml(writer);  
InBlock.gif    writer.Flush();  
InBlock.gif    Response.End();  
InBlock.gif    writer.Close();  
ExpandedSubBlockEnd.gif   }

ExpandedBlockEnd.gif  }

None.gif
None.gif 
None.gif
None.gif
---------------------------------
None.gif
None.gif仔细看看``其实完全不用在响应多个DROPLIST的时候牺牲 N
- 1  个页面,因为所有的响应都有一个共性,为什么不可以多传一个值进行判断响应那一个方法呢???
None.gif
None.gifvar type 
= " type1 " ;
None.gif
None.gif oHttpReq.open(
" post " , " webform2.aspx?state= " + state + " &type= " + type,  false );
None.gif
None.gif
None.gif  
string  type  =   this .Request[ " type " ].ToString();
None.gif
None.gif
switch (type)
None.gif
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif
InBlock.gif    
case "type1":
InBlock.gif
InBlock.gif      dot.gifdot.gifdot.gifdot.gifdot.gifdot.gifdot.gifdot.gifdot.gifdot.gifdot.gifdot.gifdot.gif..
InBlock.gif
ExpandedBlockEnd.gif}

None.gif
None.gif 
None.gif
None.gif
----------------------------------------------
None.gif
None.gif程序需要做几处修改:
None.gif
None.gif
1 、解决drp2、drp3清楚不完全的问题: drp2.innerText  = "" ;  drp3dot.gifdot.gifdot.gifdot.gifdot.gifdot.gifdot.gif..
None.gif
None.gif
2
None.gif
None.gif   
for  (var item  =  items.nextNode();item;item  =  items.nextNode())
ExpandedBlockStart.gifContractedBlock.gif     
dot.gif { 
InBlock.gif      var city 
= item.nodeTypedValue;
InBlock.gif      var newOption 
= document.createElement("OPTION"); 
InBlock.gif      newOption.text 
= city; 
InBlock.gif      newOption.value 
= city; 
InBlock.gif      drp2.options.add(newOption); 
ExpandedBlockEnd.gif      }
 
None.gif
3 、如果传多个值的问题也是一样``
None.gif
None.gifselect t1,t2 from tt
None.gif
None.gif只要多加一个条件就可以解决问题
None.gif
None.gif 
None.gif
None.gif
=======================================================
None.gif
None.gif这个还有很多可以研究的问题``比如刷新后值的问题。。。。。。。。。。。。
None.gif
None.gif
None.gif
None.gif
None.gifTrackback: http:
// tb.blog.csdn.net/TrackBack.aspx?PostId=548121
None.gif

None.gif 
None.gif
None.gif 
None.gif
None.gif程序演示地址:http:
// www.718.com.cn/other/Example.aspx
None.gif

None.gif在网上看到了一些无刷新的联动控件。下下了测试以后,显示英文和数字可以,但是不可以显示中文,后来把从网上down下来的文件做了一个翻修改,做了一个省市的联动控件。给大家共享一下。可以显示中文了。
None.gif
None.gif 
None.gif
None.gif
None.gif
None.gif
<% @ Page language = " c# "  Codebehind = " Example.aspx.cs "  AutoEventWireup = " false "  Inherits = " Webs.other.Example "   %>  
None.gif
< HTML >  
None.gif
< HEAD >  
None.gif
< title > Example </ title >  
None.gif
< meta name = " GENERATOR "  Content = " Microsoft Visual Studio .NET 7.1 " >  
None.gif
< meta name = " CODE_LANGUAGE "  Content = " C# " >  
None.gif
< meta name = " vs_defaultClientScript "  content = " JavaScript " >  
None.gif
< meta name = " vs_targetSchema "  content = " http://schemas.microsoft.com/intellisense/ie5 " >  
None.gif
< script >  
ExpandedBlockStart.gifContractedBlock.giffunction load(state)
dot.gif
InBlock.gifvar drp2 
= document.getElementById("DropDownList2"); 
ExpandedSubBlockStart.gifContractedSubBlock.gif
for (i = drp2.length; i >= 0; i--)dot.gif
InBlock.gifdrp2.options.remove(i); 
ExpandedSubBlockEnd.gif}
 
InBlock.gif
InBlock.gifvar oHttpReq 
= new ActiveXObject("MSXML2.XMLHTTP"); 
InBlock.gifvar oDoc 
= new ActiveXObject("MSXML2.DOMDocument"); 
InBlock.gif
InBlock.gifoHttpReq.open(
"POST""getData.aspx?state="+state, false); 
InBlock.gifoHttpReq.send(
""); 
InBlock.gifresult 
= oHttpReq.responseText; 
InBlock.gifoDoc.loadXML(result); 
InBlock.gifitems1 
= oDoc.selectNodes("//CITY/Table/Id"); 
InBlock.gifitems2 
= oDoc.selectNodes("//CITY/Table/shiname"); 
InBlock.gif
InBlock.gifvar itemsLength
=items1.length; 
InBlock.gif  
for(i=0;i<itemsLength;i++
InBlock.gif
InBlock.gif
//将小类的类名和编号赋予DropDownList2 
ExpandedSubBlockStart.gifContractedSubBlock.gif
  dot.gif
InBlock.gif  var newOption 
= document.createElement("OPTION"); 
InBlock.gif  newOption.text
=items2[i].text; 
InBlock.gif  newOption.value
=items1[i].text; 
InBlock.gif  drp2.options.add(newOption); 
ExpandedSubBlockEnd.gif  }
 
ExpandedBlockEnd.gif}
 
ExpandedBlockStart.gifContractedBlock.gifwindow.onload 
=  function() dot.gif {load('1');}  
None.gif
None.gif
</ script >  
None.gif
</ HEAD >  
None.gif
< body MS_POSITIONING = " FlowLayout " >  
None.gif
< form id = " Form1 "  method = " post "  runat = " server " >  
None.gif
< asp:DropDownList id = " DropDownList1 "  runat = " server " ></ asp:DropDownList >  
None.gif
< asp:DropDownList id = " DropDownList2 "  runat = " server " ></ asp:DropDownList >  
None.gif
< asp:TextBox id = " TH "  runat = " server " ></ asp:TextBox >  
None.gif
< asp:Button id = " Button1 "  runat = " server "  Text = " Button " ></ asp:Button >  
None.gif
</ form >  
None.gif
</ body >  
None.gif
</ HTML >  
None.gif
None.gif
None.gifcs源文件:
None.gif
None.gif
using  System;
None.gif
using  System.Collections;
None.gif
using  System.ComponentModel;
None.gif
using  System.Data;
None.gif
using  System.Drawing;
None.gif
using  System.Web;
None.gif
using  System.Web.SessionState;
None.gif
using  System.Web.UI;
None.gif
using  System.Web.UI.WebControls;
None.gif
using  System.Web.UI.HtmlControls;
None.gif
using  System.Data.SqlClient;
None.gif
None.gif
namespace  Webs.other
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif 
/**//// <summary>
InBlock.gif 
/// Example 的摘要说明。
ExpandedSubBlockEnd.gif 
/// </summary>

InBlock.gif public class Example : System.Web.UI.Page
ExpandedSubBlockStart.gifContractedSubBlock.gif 
dot.gif{
InBlock.gif  
protected System.Web.UI.WebControls.DropDownList DropDownList1;
InBlock.gif  
protected System.Web.UI.WebControls.TextBox TH;
InBlock.gif  
protected System.Web.UI.WebControls.Button Button1;
InBlock.gif  
protected System.Web.UI.WebControls.DropDownList DropDownList2;
InBlock.gif 
InBlock.gif  
private void Page_Load(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
// 在此处放置用户代码以初始化页面
InBlock.gif
   if(!this.IsPostBack)
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
// 建立数据源加载第一个DropDownList,也可以默认加载第二个
InBlock.gif
    SqlConnection con = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings.Get("connStr1"));
InBlock.gif    SqlDataAdapter da 
= new SqlDataAdapter("select Id,shengname from Province",con);
InBlock.gif    DataSet ds 
= new DataSet();
InBlock.gif    da.Fill(ds);
InBlock.gif    
this.DropDownList1.DataSource = ds;
InBlock.gif    
this.DropDownList1.DataTextField = "shengname";
InBlock.gif    
this.DropDownList1.DataValueField = "Id";
InBlock.gif    
this.DropDownList1.DataBind();
InBlock.gif    
// 这里是绑定客户端事件,当第一个DropDownList的选项改变时激发下面的事件onchange,这个事件将调用一个客户端方法load()
InBlock.gif
    this.DropDownList1.Attributes.Add("onchange","load(this.options[this.selectedIndex].value)");
ExpandedSubBlockEnd.gif   }

ExpandedSubBlockEnd.gif  }

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif  
Web Form Designer generated code#region Web Form Designer generated code
InBlock.gif  
override protected void OnInit(EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
//
InBlock.gif   
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
InBlock.gif   
//
InBlock.gif
   InitializeComponent();
InBlock.gif   
base.OnInit(e);
ExpandedSubBlockEnd.gif  }

InBlock.gif  
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
InBlock.gif  
/// 此方法的内容。
ExpandedSubBlockEnd.gif  
/// </summary>

InBlock.gif  private void InitializeComponent()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{    
InBlock.gif   
this.Button1.Click += new System.EventHandler(this.Button1_Click);
InBlock.gif   
this.Load += new System.EventHandler(this.Page_Load);
InBlock.gif
ExpandedSubBlockEnd.gif  }

ExpandedSubBlockEnd.gif  
#endregion

InBlock.gif
InBlock.gif  
private void Button1_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   TH.Text
=this.Request.Form["DropDownList2"].ToString();
ExpandedSubBlockEnd.gif  }

ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif 
None.gif
None.gifgetdata源文件
None.gif
None.gif 
None.gif
None.gif
using  System;
None.gif
using  System.Collections;
None.gif
using  System.ComponentModel;
None.gif
using  System.Data;
None.gif
using  System.Drawing;
None.gif
using  System.Web;
None.gif
using  System.Web.SessionState;
None.gif
using  System.Web.UI;
None.gif
using  System.Web.UI.WebControls;
None.gif
using  System.Web.UI.HtmlControls;
None.gif
using  System.Data.SqlClient;
None.gif
using  System.Xml;
None.gif
using  System.Configuration;
None.gif
using  System.Text;
None.gif
None.gif
namespace  Webs.other
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif 
/**//// <summary>
InBlock.gif 
/// GetData 的摘要说明。
ExpandedSubBlockEnd.gif 
/// </summary>

InBlock.gif public class GetData : System.Web.UI.Page
ExpandedSubBlockStart.gifContractedSubBlock.gif 
dot.gif{
InBlock.gif  
private void Page_Load(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
// 在此处放置用户代码以初始化页面
InBlock.gif   
//Response.Write(Request["state"]);
InBlock.gif
   int shengNo=int.Parse(Request["state"].ToString());   
InBlock.gif   SqlConnection con 
= new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings.Get("connStr1"));
InBlock.gif   SqlDataAdapter da 
= new SqlDataAdapter("select Id,shiname from City where Shengid='"+shengNo+"'",con);
InBlock.gif   DataSet ds 
= new DataSet("CITY");
InBlock.gif   da.Fill(ds);
InBlock.gif
InBlock.gif   XmlTextWriter writer 
= new XmlTextWriter(Response.OutputStream,Encoding.UTF8);
InBlock.gif   writer.Formatting 
= Formatting.Indented;
InBlock.gif   writer.Indentation 
= 4;
InBlock.gif   writer.IndentChar 
= ' ';
InBlock.gif   writer.WriteStartDocument();
InBlock.gif   ds.WriteXml(writer);
InBlock.gif   writer.Flush();
InBlock.gif   Response.End();
InBlock.gif   writer.Close();   
ExpandedSubBlockEnd.gif  }

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif  
Web Form Designer generated code#region Web Form Designer generated code
InBlock.gif  
override protected void OnInit(EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
//
InBlock.gif   
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
InBlock.gif   
//
InBlock.gif
   InitializeComponent();
InBlock.gif   
base.OnInit(e);
ExpandedSubBlockEnd.gif  }

InBlock.gif  
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
InBlock.gif  
/// 此方法的内容。
ExpandedSubBlockEnd.gif  
/// </summary>

InBlock.gif  private void InitializeComponent()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{    
InBlock.gif   
this.Load += new System.EventHandler(this.Page_Load);
ExpandedSubBlockEnd.gif  }

ExpandedSubBlockEnd.gif  
#endregion

ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
None.gif
None.gif
None.gif
None.gifTrackback: http:
// tb.blog.csdn.net/TrackBack.aspx?PostId=472917
None.gif

None.gif
None.gif 
None.gif
None.gif ASP.net DropDownList 无刷新联动! 
None.gif
< TITLE > WebForm2 </ TITLE >
None.gif  
< SCRIPT language = ' javascript ' >  
ExpandedBlockStart.gifContractedBlock.gif  function load()
dot.gif
InBlock.gif    var drp2 
= document.getElementById("DropDownList2"); 
InBlock.gif    drp2.innerText
="";
ExpandedSubBlockStart.gifContractedSubBlock.gif    
for(var i = 0;i<=drp2.options.length -1;i++)dot.gif
InBlock.gif     drp2.remove(i); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif    var drp3 
= document.getElementById("DropDownList3"); 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
for(var i = 0;i<=drp3.options.length -1;i++)dot.gif
InBlock.gif     drp3.remove(i); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif    var xmlhttp 
= new ActiveXObject("MSXML2.XMLHTTP"); 
InBlock.gif    var oDoc 
= new ActiveXObject("MSXML2.DOMDocument"); 
InBlock.gif    var state
=document.getElementById("DropDownList1").value;
InBlock.gif    xmlhttp.open(
"POST""webform1.aspx?id="+state,false);
InBlock.gif    xmlhttp.send(
"");
InBlock.gif    var res
=oDoc.loadXML(xmlhttp.responseText);
InBlock.gif    var naItems 
= oDoc.selectNodes("//Market/Table/maName"); 
InBlock.gif    var idItems 
= oDoc.selectNodes("//Market/Table/maId"); 
InBlock.gif    var item;
InBlock.gif    var id;
ExpandedSubBlockStart.gifContractedSubBlock.gif    
for (item = naItems.nextNode(),id=idItems.nextNode(); item&&id; item = naItems.nextNode(),id=idItems.nextNode())dot.gif
InBlock.gif     var nastr 
= item.nodeTypedValue; 
InBlock.gif     var idstr 
= id.nodeTypedValue;
InBlock.gif     var newOption 
= document.createElement("OPTION"); 
InBlock.gif     newOption.text 
=nastr; 
InBlock.gif     newOption.value 
= idstr; 
InBlock.gif     
InBlock.gif     
InBlock.gif     drp2.options.add(newOption); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif    load2();
InBlock.gif  
ExpandedBlockEnd.gif  }
 
ExpandedBlockStart.gifContractedBlock.gif  function load2()
dot.gif
InBlock.gif    var drp2 
= document.getElementById("DropDownList3"); 
InBlock.gif    drp2.innerText
="";
ExpandedSubBlockStart.gifContractedSubBlock.gif    
for(var i = 0;i<=drp2.options.length -1;i++)dot.gif
InBlock.gif     drp2.remove(i); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif    var xmlhttp 
= new ActiveXObject("MSXML2.XMLHTTP"); 
InBlock.gif    var oDoc 
= new ActiveXObject("MSXML2.DOMDocument"); 
InBlock.gif    var state
=document.getElementById("DropDownList2").value;
InBlock.gif    xmlhttp.open(
"POST""webform3.aspx?id="+state,false);
InBlock.gif    xmlhttp.send(
"");
InBlock.gif    var res
=oDoc.loadXML(xmlhttp.responseText);
InBlock.gif    var naItems 
= oDoc.selectNodes("//Market/Table/maName"); 
InBlock.gif    var idItems 
= oDoc.selectNodes("//Market/Table/maId"); 
InBlock.gif    var item;
InBlock.gif    var id;
ExpandedSubBlockStart.gifContractedSubBlock.gif    
for (item = naItems.nextNode(),id=idItems.nextNode(); item&&id; item = naItems.nextNode(),id=idItems.nextNode())dot.gif
InBlock.gif     var nastr 
= item.nodeTypedValue; 
InBlock.gif     var idstr 
= id.nodeTypedValue;
InBlock.gif     var newOption 
= document.createElement("OPTION"); 
InBlock.gif     newOption.text 
=nastr; 
InBlock.gif     newOption.value 
= idstr; 
InBlock.gif     
InBlock.gif     
InBlock.gif     drp2.options.add(newOption); 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif  
ExpandedBlockEnd.gif  }
 
None.gif  
</ SCRIPT >
None.gif 
</ HEAD >
None.gif 
< BODY ms_positioning = " GridLayout "  onload = " load() " >
None.gif  
< FORM id = " Form1 "  method = " post "  runat = " server " >
None.gif   
< ASP:DROPDOWNLIST id = " DropDownList1 "  runat = " server " ></ ASP:DROPDOWNLIST >
None.gif   
< ASP:DROPDOWNLIST id = " DropDownList2 "  runat = " server " ></ ASP:DROPDOWNLIST >
None.gif   
< ASP:DROPDOWNLIST id = " Dropdownlist3 "  runat = " server " ></ ASP:DROPDOWNLIST >
None.gif  
</ FORM >
None.gif 
</ BODY >
None.gif
</ HTML >
None.gif
-----------------------
None.gif
namespace  dropDown
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif 
/**//// <summary>
InBlock.gif 
/// WebForm2 的摘要说明。
ExpandedSubBlockEnd.gif 
/// </summary>

InBlock.gif public class WebForm2 : System.Web.UI.Page
ExpandedSubBlockStart.gifContractedSubBlock.gif 
dot.gif{
InBlock.gif  
protected System.Web.UI.WebControls.DropDownList DropDownList1;
InBlock.gif  
protected System.Web.UI.WebControls.DropDownList Dropdownlist3;
InBlock.gif  
protected System.Web.UI.WebControls.DropDownList DropDownList2;
InBlock.gif 
InBlock.gif  
private void Page_Load(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
// 在此处放置用户代码以初始化页面
InBlock.gif
   if(!this.IsPostBack)
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    SqlConnection con 
= new SqlConnection("server=localhost;database=star;uid=sa;pwd="); 
InBlock.gif    SqlDataAdapter da 
= new SqlDataAdapter("select maId,maName from tabMarket  where maCls=0",con); 
InBlock.gif    DataSet ds 
= new DataSet(); 
InBlock.gif    da.Fill(ds,
"op");
InBlock.gif    
this.DropDownList1.DataSource=ds.Tables[0];
InBlock.gif    
this.DropDownList1.DataTextField = "maName"
InBlock.gif    
this.DropDownList1.DataValueField = "maId"
InBlock.gif    
this.DropDownList1.DataBind(); 
InBlock.gif    
this.DropDownList1.Attributes.Add("onchange","load()"); 
InBlock.gif    
this.DropDownList2.Attributes.Add("onchange","load2()");
ExpandedSubBlockEnd.gif   }
 
InBlock.gif
InBlock.gif
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif}

None.gif
-----------------------
None.gif
public   class  WebForm1 : System.Web.UI.Page
ExpandedBlockStart.gifContractedBlock.gif 
dot.gif {
InBlock.gif 
InBlock.gif  
private void Page_Load(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
// 在此处放置用户代码以初始化页面
InBlock.gif   
// Put user code to initialize the page here 
InBlock.gif   
//if(this.Request["state"]!=null)
InBlock.gif   
//{  
InBlock.gif
     string id =this.Request["id"]; 
InBlock.gif    SqlConnection con 
= new SqlConnection("server=localhost;database=star;uid=sa;pwd=;"); 
InBlock.gif    SqlDataAdapter da 
= new SqlDataAdapter("select maName,maId  from tabMarket where maParent=@id and maSt=1 ",con); 
InBlock.gif       da.SelectCommand.Parameters.Add(
"@id",id);
InBlock.gif    DataSet ds 
= new DataSet("Market"); 
InBlock.gif    da.Fill(ds); 
InBlock.gif   
InBlock.gif       ds.WriteXml(Response.OutputStream);
InBlock.gif       Response.Flush ();
InBlock.gif       Response.End ();
InBlock.gif       
InBlock.gif   
//}
ExpandedSubBlockEnd.gif
  }

ExpandedBlockEnd.gif       }

None.gif
-----------------------------
None.gif 
public   class  WebForm3 : System.Web.UI.Page
ExpandedBlockStart.gifContractedBlock.gif 
dot.gif {
InBlock.gif  
private void Page_Load(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
// 在此处放置用户代码以初始化页面
InBlock.gif
   string id =Request["id"]; 
InBlock.gif   SqlConnection con 
= new SqlConnection("server=localhost;database=star;uid=sa;pwd=;"); 
InBlock.gif   SqlDataAdapter da 
= new SqlDataAdapter("select maName,maId  from tabMarket where maParent=@id and maSt=1",con); 
InBlock.gif   da.SelectCommand.Parameters.Add(
"@id",id);
InBlock.gif   DataSet ds 
= new DataSet("Market"); 
InBlock.gif   da.Fill(ds); 
InBlock.gif   
InBlock.gif   ds.WriteXml(Response.OutputStream);
InBlock.gif   Response.Flush ();
InBlock.gif   Response.End ();
ExpandedSubBlockEnd.gif  }

ExpandedBlockEnd.gif       }

None.gif
None.gif

转载于:https://www.cnblogs.com/jhobo/archive/2006/11/13/558951.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值