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 ...
随机推荐
- Greg and Array
Codeforces Round #179 (Div. 2) C:http://codeforces.com/problemset/problem/296/C 题意:给你一个序列,然后有两种操作,第一 ...
- 【UVA1379】Pitcher Rotation (贪心+DP)
题意: 你经营者一直棒球队.在接下来的g+10天中有g(3<=g<=200)场比赛,其中每天最多一场比赛.你已经分析出你的n(5<=n<=100)个投手中每个人对阵所有m个对手 ...
- Bitmap介绍
转自:http://blog.csdn.net/xgdofull/article/details/5424611 简单的说就是用数组存放若有数据就标志为1或true,若不存在标志为0或false.比如 ...
- 初次踏上GUI编程之路(有点意思,详细介绍了菜鸟的学习之路)
初次踏上GUI编程之路 —— 我的Qt学习方法及对Qt认识的不断转变 -> 开始接触GUI与开始接触Qt: 话说,我第一次看见“Qt”这一个名词,好像是在CSDN网站的主页上吧,因为CSDN好像 ...
- 有感,懂市场比懂产品重要,懂产品比懂技术重要——想起凡客诚品和YY语音了
一个创业公司,最好三样都要有,但应该CEO是懂市场,经理懂产品,程序员最好懂技术厉害一点-这还不算,销售也要厉害一点,不能守株待兔- 美工——有钱最好请个美工,最起码也要请人设计修改一下- 财务——不 ...
- Android SectionIndexer 的使用(联系人分类索引)
// 获取标题栏索引 int position = sectionIndexter.getPositionForSection(l[idx]); ) { return true; } // 设置调整到 ...
- mysql 海量数据的存储和访问解决方案
第1章 引言 随着互联网应用的广泛普及,海量数据的存储和访问成为了系统设计的瓶颈问题.对于一个大型的互 联网应用,每天几十亿的PV无疑对数据库造成了相当高的负载.对于系统的稳定性和扩展性造成了极大的 ...
- 中国版 Azure 现提供 Azure Traffic Manager
Stephen MaloneAzure网络 - DNS和 Traffic Manager高级项目经理 我们非常高兴地宣布,中国版 Azure中现已提供 Azure Traffic Manager.Az ...
- 使用VisualStudio进行单元测试之四 顺序测试
前文中所提到的测试都是针对一个方法进行的独立测试,即使是同事测试多个方法,他们之间也没有影响.但是在实际的生产过程中,更多的情况是方法与方法之间是存在相互的逻辑关系的,所以也就有了今天要介绍的顺序测试 ...
- oracle查询语句2【转载】
本文使用的实例表结构与表的数据如下: scott.emp员工表结构如下: SQL> DESC SCOTT.EMP; Name Type Nullable Defaul ...