CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
【经验总结】不能实施并行处理的情况 浅谈并行编程中的任务分解模式
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  ASP.NET

.net ajax实现(请求解决)

楼主zjx_sir(享受孤独,犹如孤独享受你。)2005-11-22 10:34:20 在 .NET技术 / ASP.NET 提问

三个   dropdownlist   和一个DataGrid    
  实现:  
  第一个   dropdownlist   ->   第二个   dropdownlist   ->第三个dropdownlist   数据  
  ->DataGrid   邦定  
  如何实现   有没有源码 问题点数:100、回复次数:12Top

1 楼jxzhang615(冰河)回复于 2005-11-22 10:36:48 得分 0

帮顶Top

2 楼fphuang(人在哈尔滨·四月)回复于 2005-11-22 10:47:26 得分 30

我这里有一个四个dropdownlist   连动的代码,如需要给我发个短消息副上你的邮件地址Top

3 楼lovefootball(蟑螂(生活就是扯淡--做人要放低姿态))回复于 2005-11-22 10:56:27 得分 0

dropdownlist   联动可以参考门槛的blog  
  至于datagrid原理也是差不多Top

4 楼fangbuge(窗外的雨)回复于 2005-11-22 11:36:36 得分 0

前面的dropdownlist很好实现:JS-->WEBSERVICE.  
  不过后面的绑定DATAGRID就不知道了.好象是很难吧!因为JS中没有DATASET对象.Top

5 楼ph580(.Net,我喜欢!www.bjcan.com/hengxing)回复于 2005-11-22 11:46:30 得分 15

无刷新XMLHTTP实现二级联动下拉框    
  给你一个完整的无刷新XMLHTTP实现二级联动下拉框的完整示例,你参考一下,根据意思,可轻易做出多级来.  
  以下为页面代码:  
   
  <form   id="Form1"   method="post"   runat="server">  
  <asp:DropDownList   id="DropDownList1"   runat="server"></asp:DropDownList>  
  <asp:DropDownList   id="DropDownList2"   runat="server"></asp:DropDownList>  
  <SCRIPT   LANGUAGE="JavaScript">  
  <!--  
  //以XML求取数据  
  function   XmlPost(obj)  
  {  
    var   svalue   =   obj.value;  
    var   webFileUrl   =   "?brc_id="   +   svalue;  
    var   result   =   "";  
    var   xmlHttp   =   new   ActiveXObject("MSXML2.XMLHTTP");  
    xmlHttp.open("POST",   webFileUrl,   false);  
    xmlHttp.send("");  
    result   =   xmlHttp.responseText;  
      
    if(result   !=   "")  
    {  
      document.all("DropDownList2").length=0;  
      var   piArray   =   result.split(",");  
      for(var   i=0;i<piArray.length;i++)  
      {  
        var   ary1   =   piArray[i].toString().split("|");  
        //alert(ary1[0].toString());  
        document.all("DropDownList2").options.add(new   Option(ary1[1].toString(),ary1[0].toString()));  
      }  
    }  
    else  
    {  
      alert(result);  
    }  
  }  
  //-->  
  </SCRIPT>      
  </form>  
   
  以下为后台代码:  
   
  private   System.Data.OleDb.OleDbConnection   conn;  
   
  private   DataTable   get_dt(string   sql)  
  {  
    string   connstr   =   "Provider=MSDAORA.1;Password=aqjc;User   ID=aqjc;Data   Source=aqjc";  
    this.conn   =   new   OleDbConnection(connstr);  
    this.conn.Open();  
    OleDbCommand   myOleDbCommand   =   new   OleDbCommand(sql,this.conn);  
    OleDbDataAdapter   myData   =   new   OleDbDataAdapter(myOleDbCommand);  
   
    DataSet   myDataset   =   new   DataSet();  
    try  
    {  
      myData.Fill(myDataset);  
    }  
    catch(Exception   ex)  
    {  
      throw   ex;  
    }  
   
    this.conn.Close();  
    return   myDataset.Tables[0];    
  }  
   
  private   void   Page_Load(object   sender,   System.EventArgs   e)  
  {  
    string   brc_id   =   this.Request.QueryString["brc_id"];  
    if(brc_id   +   "a"   !=   "a")  
    {  
      this.down2_bind(brc_id);  
    }  
   
    if(!this.IsPostBack)  
    {  
      this.down1_bind();  
    }  
  }  
   
  ///   <summary>  
  ///   返回第2个下拉框需要的值给xmlhttp  
  ///   </summary>  
  ///   <param   name="brc_id"></param>  
  private   void   down2_bind(string   brc_id)  
  {  
    string   mystr   =   "";  
    string   sql   =   "select   brc_id,brc_name   from   asm_branch   where   brc_parentid   =   '"   +   brc_id   +   "'";  
    DataTable   mytab   =   this.get_dt(sql);  
   
    if(mytab.Rows.Count   !=   0)  
    {  
      for(int   i=0;i<mytab.Rows.Count;i++)  
      {  
        mystr   +=   ","   +   mytab.Rows[i][0].ToString()   +   "|"   +   mytab.Rows[i][1].ToString();  
      }  
      mystr   =   mystr.Substring(1);  
    }  
    this.Response.Write(mystr);  
    this.Response.End();  
  }  
   
  ///   <summary>  
  ///   绑定第一个下拉框  
  ///   </summary>  
  private   void   down1_bind()  
  {  
    string   sql   =   "select   brc_id,brc_name   from   asm_branch   where   brc_level   =   '1'";  
    DataTable   mytab   =   this.get_dt(sql);  
    this.DropDownList1.DataSource   =   mytab;  
    this.DropDownList1.DataValueField   =   "brc_id";  
    this.DropDownList1.DataTextField   =   "brc_name";  
    this.DropDownList1.DataBind();  
    this.DropDownList1.Attributes.Add("onchange","XmlPost(this);");  
  }  
     
       
  Top

6 楼Richard_Hong(武昌鱼)回复于 2005-11-22 12:06:06 得分 25

给你个例子,实现三个按钮的互动  
  ////////////////  
  //   aspx文件  
  ////////////////  
   
  <HTML>  
  <HEAD>  
  <title>TreeDropDownList</title>  
  <meta   content="Microsoft   Visual   Studio   7.0"   name="GENERATOR">  
  <meta   content="C#"   name="CODE_LANGUAGE">  
  <meta   content="JavaScript"   name="vs_defaultClientScript">  
  <meta   content="http://schemas.microsoft.com/intellisense/ie5"   name="vs_targetSchema">  
  <script   language="javascript">  
   
  var   Wantcount;  
  var   Groupcount;  
   
  Groupcount=0;  
   
  Group   =   new   Array();  
  <asp:Literal   id="Want"   runat="server"></asp:Literal>  
   
  function   changelocation1(locationid)  
  {  
  document.submit.DirectionList1.length   =   0;  
  document.submit.WantList1.length   =   0;  
  var   locationid=locationid;  
  var   i;  
  var   flag;  
  var   j;  
  for   (i=0;i<Groupcount;   i++)  
  {  
  if   (Group[i][0]   ==   locationid)  
  {  
  flag   =   true;  
  for   (j   =0;j<document.submit.DirectionList1.length;j++)  
  if   (document.submit.DirectionList1[j].value   ==   Group[i][1])  
  {  
  flag   =   false;  
  break;  
  }  
  if   (flag)  
  document.submit.DirectionList1.options[document.submit.DirectionList1.length]  
  =   new   Option(Group[i][1],   Group[i][1]);  
  }  
  }  
  }  
   
   
  function   changelocation11(locationid,   direction)  
  {  
  document.submit.WantList1.length   =   0;  
  var   locationid=locationid;  
  var   i;  
  var   flag;  
  var   j;  
  for   (i=0;i<Groupcount;i++)  
  {  
  if   (Group[i][0]   ==   locationid   &&   Group[i][1]   ==   direction)  
  {  
           
  flag   =   true;  
  for   (j=0;j<document.submit.WantList1.length;j++)  
  if   (document.submit.WantList1[j].value   ==   Group[i][2])  
  {  
  flag   =   false;  
  break;  
  }  
  if   (flag)  
  document.submit.WantList1.options[document.submit.WantList1.length]  
  =   new   Option(Group[i][2],   Group[i][2]);  
  }  
  }  
  }  
   
  </script>  
  </HEAD>  
  <BODY   ms_positioning="GridLayout">  
  <form   id="submit"   method="post"   runat="server">  
  <TABLE   style="Z-INDEX:   101;   LEFT:   184px;   POSITION:   absolute;   TOP:   144px">  
  <TR>  
  <TD   style="WIDTH:   115px;   HEIGHT:   17px"   align="middle">求职意向:</TD>  
  <TD   style="HEIGHT:   17px"><asp:dropdownlist   id="SourceList1"   runat="server"   DataTextField="v_source"   DataValueField="v_source"   onchange="changelocation1(document.submit.SourceList1.options[document.submit.SourceList1.selectedIndex].value);changelocation11(document.submit.SourceList1.options[document.submit.SourceList1.selectedIndex].value,document.submit.DirectionList1.options[document.submit.DirectionList1.selectedIndex].value)"   Width="100px"></asp:dropdownlist><asp:dropdownlist   id="DirectionList1"   runat="server"   DataValueField="v_GroupName"   onchange="changelocation11(document.submit.SourceList1.options[document.submit.SourceList1.selectedIndex].value,document.submit.DirectionList1.options[document.submit.DirectionList1.selectedIndex].value)"   Width="100px"></asp:dropdownlist><asp:dropdownlist   id="WantList1"   runat="server"   DataValueField="v_title"   Width="100px"></asp:dropdownlist></TD>  
  </TR>  
  </TABLE>  
  </form>  
  <script   language="javascript">  
  changelocation1(document.submit.SourceList1.options[document.submit.SourceList1.selectedIndex].value);  
  changelocation11(document.submit.SourceList1.options[document.submit.SourceList1.selectedIndex].value,document.submit.DirectionList1.options[document.submit.DirectionList1.selectedIndex].value)  
  </script>  
  </BODY>  
  </HTML>  
   
  ///////////////  
  //   aspx.cs文件  
  ///////////////  
  public   class   TowDropDownList   :   System.Web.UI.Page  
  {  
  protected   System.Web.UI.WebControls.Literal   Want;  
  protected   System.Web.UI.WebControls.DropDownList   SourceList1;  
  protected   System.Web.UI.WebControls.DropDownList   DirectionList1;  
  protected   System.Web.UI.WebControls.DropDownList   WantList1;  
  protected   System.Web.UI.WebControls.Literal   Group;  
   
  private   void   Page_Load(object   sender,   System.EventArgs   e)  
  {  
  if   (!IsPostBack)  
  {  
  DataSet   ds   =   new   DataSet();  
  ds.ReadXml(Server.MapPath("DataSource.xml"));  
  for(int   i   =   0;i   <ds.Tables[0].Rows.Count   ;i++)  
  {  
  DataRow   dr   =   ds.Tables[0].Rows[i];  
  Want.Text   +=   String.Format("Group[Groupcount++]   =   new   Array(\"{0}\",\"{1}\",\"{2}\");\n",   dr["v_Source"],dr["v_GroupName"].ToString(),   dr["v_title"].ToString());  
  if   (SourceList1.Items.FindByText(dr["v_Source"].ToString())   ==   null)  
  {  
  SourceList1.Items.Add(dr["v_Source"].ToString());  
  }  
  }  
  }  
  }  
   
  #region   Web   Form   Designer   generated   code  
  override   protected   void   OnInit(EventArgs   e)  
  {  
  //  
  //   CODEGEN:该调用是   ASP.NET   Web   窗体设计器所必需的。  
  //  
  InitializeComponent();  
  base.OnInit(e);  
  }  
   
  ///   <summary>  
  ///   设计器支持所需的方法   -   不要使用代码编辑器修改  
  ///   此方法的内容。  
  ///   </summary>  
  private   void   InitializeComponent()  
  {          
  this.Load   +=   new   System.EventHandler(this.Page_Load);  
   
  }  
  #endregion  
  }  
  Top

7 楼singlepine(小山)回复于 2005-11-22 12:29:10 得分 30

XmlHttp实现无刷新三联动下拉框  
  http://singlepine.cnblogs.com/articles/265678.html  
  datagrid中绑定dropdownlist  
  http://singlepine.cnblogs.com/articles/266538.htmlTop

8 楼fphuang(人在哈尔滨·四月)回复于 2005-11-22 12:47:46 得分 0

 
  [   发送成功   ]    
   
  邮件已通过病毒扫描    
   
  您已经成功将信发送到:   zjx_sir@126.com  
   
     
  已经发送,请查收!Top

9 楼zjx_sir(享受孤独,犹如孤独享受你。)回复于 2005-11-22 15:08:18 得分 0

谢谢大家   问题解决后   结贴Top

10 楼camelials(星期五)回复于 2005-11-22 15:26:13 得分 0

可以在这里搜索一下,无刷新联动DDL.用的是xmlhttpTop

11 楼zjx_sir(享受孤独,犹如孤独享受你。)回复于 2005-11-23 10:28:29 得分 0

为什么写在用户控件不行呢Top

12 楼WJY2003(笨笨鸟儿啄NET)回复于 2005-11-24 20:16:09 得分 0

真不错  
  好好学学Top

相关问题

  • 请求AJAX资料
  • ajax技术请求
  • asp .net中删除操作前的“请求确认”一般用什么方法实现的呢
  • 菜鸟问:VB如何实现发送http请求?(Pls come in.)
  • 对LoadFrame的函数内部实现的不解,请求帮助!
  • 请求栈以及队列的算法实现源程序c
  • 请求栈 的算法实现c源程序
  • 请教:两服务器之间的HTTP请求(非RMI实现)
  • 用Java向Web站点发送POST请求,怎么实现?
  • 有没有办法实现这个小小的请求啊?

关键词

得分解答快速导航

  • 帖主:zjx_sir
  • fphuang
  • ph580
  • Richard_Hong
  • singlepine

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
惹火投票。。火热进行中...
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
CSDN网站24小时值班电话:13552009689
Copyright © 2000-2009, CSDN.NET, All Rights Reserved
GongshangLogo