IsPostBack and DropdownList.
Encounted the issue accident when helping my classmate dealing with his homework assignment,it turns out that I have to consider about 'IsPostBack' when trying to combind the 'DropdownList' in code behind(or it won't get what we expect):
protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
Response.Write("<script>alert('Is not PostBack')</script>");
ddlstSinger.Items.Clear();
adapter = new t_musicTableAdapter();
var data = from d in adapter.GetData().AsQueryable()
group d by d.singer
into mySinger
select mySinger.First();
foreach (var d in data) {
ddlstSinger.Items.Add(d.singer);
}
}
}
protected void btnSearch_Click(object sender, EventArgs e) {
if (ddlstSinger.SelectedItem == null) {
Alert("Please enter the search condition!");
return;
}
lbInvisible.Text = ddlstSinger.Text;
lvwSearch.DataSourceID = "ObjectDataSrcSearch";
lvwSearch.DataBind();
}
IsPostBack and DropdownList.的更多相关文章
- "不能在 DropDownList 中选择多个项。"其解决办法及补充
探讨C#.NET下DropDownList的一个有趣的bug及其解决办法 摘要: 本文就C#.Net 环境下Web开发中经常使用的DropDownList控件的SelectedIndex属性进行了详细 ...
- Asp.Net 将枚举类型(enum)绑定到ListControl(DropDownList)控件
在开发过程中一些状态的表示使用到枚举类型,那么如何将枚举类型直接绑定到ListControl(DropDownList)是本次的主题,废话不多说了,直接代码: 首先看工具类代码: /// <su ...
- 怎么取得dropdownlist选中的ID值
把数据库绑定在dropdownlist中,然后把选中的dropdownlist的项的ID值保存在另外的一个数据库中.怎么取得dropdownlist选中的ID值呢?? this.DropDownLis ...
- DropDownList控件
1.DropDownList控件 <asp:DropDownList runat="server" ID="DropDownList1" AutoPost ...
- 省市县三级联动(webFrom...DropdownList)
编辑页面 <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"&g ...
- 用DropDownList实现的省市级三级联动
这是一个用DropDownList 实现的省市级三级联动,记录一下········ <asp:ScriptManager ID="ScriptManager1" runat= ...
- 两个dropDownList和一个GridView的选择与显示
很久没有写ASP.NET了,今天有看到论坛上一个问题:"两个dropDownList和一个GridView,已经进行了数据绑定,现在想让第一个下拉菜单的数据改变时,第二个下拉菜单自动变到相应 ...
- ASP.NET Repeater 绑定 DropDownList Calendar 选择日期
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- DropDownList 控件不能触发SelectedIndexChanged 事件
相信DropDownList 控件不能触发SelectedIndexChanged 事件已经不是什么新鲜事情了,原因也无外乎以下几种: 1.DropDownList 控件的属性 AutoPostBac ...
随机推荐
- Oracle RAC的五大优势及其劣势
Oracle RAC的五大优势及其劣势 不同的集群产品都有自己的特点,RAC的特点包括如下几点: 双机并行.RAC是一种并行模式,并不是传统的主备模式.也就是说,RAC集群的所有成员都可以同时接收客户 ...
- 利用python分析nginx日志
最近在学习python,写了个脚本分析nginx日志,练练手.写得比较粗糙,但基本功能可以实现. 脚本功能:查找出当天访问次数前十位的IP,并获取该IP来源,并将分析结果发送邮件到指定邮箱. 实现前两 ...
- 在Windows Server 2012 上安装Exchange 2013 服务器
前文:http://www.cnblogs.com/Liangw/archive/2011/09/19/2559944.html 安装准备: 1.加入一个存在的域(?如何建立一个域) 2.登录Wind ...
- octopress添加回到顶部按钮
准备回到顶部的png图片一枚,可以随自己喜好google.分享我的 取名top.png,保存在octopress/source/images/top.png octopress/source/_inc ...
- Java 集合框架 ArrayList 源码剖析
总体介绍 ArrayList实现了List接口,是顺序容器,即元素存放的数据与放进去的顺序相同,允许放入null元素,底层通过数组实现.除该类未实现同步外,其余跟Vector大致相同.每个ArrayL ...
- 4 hbase表结构 + hbase集群架构及表存储机制
本博文的主要内容有 .hbase读取数据过程 .HBase表结构 .附带PPT http://hbase.apache.org/ 读写的时候,就需要用hbase了,换句话说,就是读写的时候. ...
- 佛山Uber优步司机奖励政策(1月25日~1月31日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- Little Kings - SGU 223(状态压缩)
题目大意:在一个N*N的棋盘上放置M个国王,已知国王会攻击与它相邻的8个格子,要求放置的额国王不能相互攻击,求放置的方式有多少种. 分析:用dp[row][state][nOne],表示本行状态sta ...
- java_method_readFile读取文件文本txt
/** * @Title: TxtAndCsvUtils.java * @Package cn.com.qmhd.tools * @Description: TODO(读取txt和CSV文档) * @ ...
- maven 私服 配置 转
3 . Nexus预置的仓库 点击左侧 Repositories 链接,查看 Nexus 内置的仓库: Nexus 的仓库分为这么几类: hosted 宿主仓库:主要用于部署无法从公共仓库获取的构件( ...