CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  ASP.NET

一个问题。关于DropDownList

楼主glatiator(C++)2005-06-04 14:08:18 在 .NET技术 / ASP.NET 提问

我的DropDownList绑定了一个数据库表的列~  
  想请教的是,我怎么样才能使DropDownList里面的元素能够根据选择不同的元素可以  
  让DataGrid控件绑定不同的表?? 问题点数:20、回复次数:6Top

1 楼hjf1223(阿不)回复于 2005-06-04 14:16:34 得分 0

在DropDownList   的   SelectedIndexChanged   事件去写代码就行了。Top

2 楼njmaxiang()回复于 2005-06-04 14:36:12 得分 0

DropDownList的AutoPostBack属性设为true然后在SelectedIndexChanged   事件去写代码Top

3 楼glatiator(C++)回复于 2005-06-04 14:54:24 得分 0

就是想问的是具体代码的写法,每选定一个DropDownList元素  
  都能够绑定不同的数据表到datagrid中  
  就象数据库中我4个表,分别是user,customer,pp,oo  
  我绑定user   的一个字段进DropDownList  
  当我从里面选择一个元素时(不同的元素连接的表不同)  
  可以绑定customer,pp,oo到我的datagrid中  
  Top

4 楼tbmlh(成林)回复于 2005-06-04 14:56:48 得分 0

楼上正解。Top

5 楼LaoDai_Net(『老代』)回复于 2005-06-04 15:08:07 得分 20

aspx   code  
   
  <asp:DropDownList   id="dropTable"   style="Z-INDEX:   108;   LEFT:   104px;   POSITION:   absolute;   TOP:   456px"  
  runat="server"   AutoPostBack="True">  
  <asp:ListItem   Value="1">User表</asp:ListItem>  
  <asp:ListItem   Value="2">customer表</asp:ListItem>  
  <asp:ListItem   Value="3">pp表</asp:ListItem>  
  <asp:ListItem   Value="4">00表</asp:ListItem>  
  </asp:DropDownList>  
   
  cs   code  
   
  private   void   dropTable_SelectedIndexChanged(object   sender,   System.EventArgs   e)  
  {  
  int   selectValue   =   Int32.Parse(dropTable.SelectedItem.Value);  
  switch   (selectValue)  
  {  
  case   1:  
  BindDataUser();  
  break;  
  case   2:  
  BindDataCustoner();  
  break;  
  case   3:  
  BindDataPP();  
  break;  
  case   4:  
  BindDataOO();  
  break;  
  default:  
  BindDataUser();  
  break;  
   
  }  
  }  
   
  private   void   BindDataUser()  
  {  
  //绑定代码略  
  }  
  private   void   BindDataCustoner()  
  {  
  //绑定代码略  
  }  
  private   void   BindDataPP()  
  {  
  //绑定代码略  
  }  
  private   void   BindDataOO()  
  {  
  //绑定代码略  
  }Top

6 楼jz630(姜喆)回复于 2005-06-04 15:11:01 得分 0

SelectedIndexChanged   事件去写代码  
  可根据所选的值的不同而确定执行不同的存储过程,或SQL语句。  
  楼主不是连查看表的SQL都不会写吧?Top

相关问题

  • DropDownList
  • DropDownList
  • dropdownlist?
  • Dropdownlist Tree
  • dropdownlist的问题
  • DropDownList的问题.......
  • DropDownList 问题
  • DropDownList问题?
  • dropdownlist问题
  • 关于DropDownList

关键词

  • 代码
  • dropdownlist
  • 表
  • 绑定
  • binddatauser
  • selectedindexchanged
  • 元素
  • 不同
  • pp
  • 事件去写

得分解答快速导航

  • 帖主:glatiator
  • LaoDai_Net

相关链接

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

广告也精彩

反馈

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