日期:2014-05-16 浏览次数:20818 次
if!page.ispostback...
protected void Page_Load(object sender, EventArgs e) {
if(!page.ispostback)
{
ddlstSinger.Items.Clear();
var 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("请输入查询条件!");
return;
}
ObjectDataSrcSearch.SelectParameters.Clear();
ObjectDataSrcSearch.SelectMethod = "GetDataByName";
ObjectDataSrcSearch.SelectParameters.Add("singer", ddlstSinger.Text);
lvwSearch.DataSourceID = "ObjectDataSrcSearch";
lvwSearch.DataBind();
ObjectDataSrcSearch.Select();
}