DropDownList标志控件的学习
2007-12-03 11:16
148 查看
邦定数据方法一
dbconnection conn = new dbconnection();
DataTable dt_game = new DataTable();
string sql_game = "SELECT GamesID,CName,Season,type FROM Games_Info order by Cname";
dt_game = conn.ExecuteSelectTable(sql_game);
ListItem first_Item = new ListItem();
first_Item.Value = "0";
first_Item.Text = "";
GamesID.Items.Add(first_Item);
// MatchID.Items.Add(first_Item);
foreach (DataRow dr in dt_game.Rows)
...{
ListItem li_game = new ListItem();
li_game.Text = dr["CName"].ToString();
li_game.Value = dr["GamesID"].ToString();
GamesID.Items.Add(li_game);
}
方法二
//*****填充nationid(dropdownlist)的选项
string sql = "SELECT * FROM Nations_Info order by CName";
dbconnection conn = new dbconnection();
DataTable dt = new DataTable();
dt = conn.ExecuteSelectTable(sql);
nationid.DataSource = dt.DefaultView;
nationid.DataTextField = "CName"; //dropdownlist的Text的字段
nationid.DataValueField = "NationID";//dropdownlist的Value的字段
nationid.DataBind();
取得他选项的value
protected void GamesID_SelectedIndexChanged(object sender, EventArgs e) ...{
dbconnection conn = new dbconnection();
DataTable dt_match = new DataTable();
string sql_match = "select m.MatchID,t1.CName as HomeTeamCName,t2.CName as AwayTeamCname,m.StartTime from Matchs_Info m inner join Teams_Info t1 on m.HomeTeamID = t1.TeamID inner join Teams_Info t2 on m.AwayTeamID = t2.TeamID where m.flag=3 and m.GamesID= " + GamesID.SelectedValue.ToString() + " order by m.matchid desc";
dt_match = conn.ExecuteSelectTable(sql_match);
foreach (DataRow dr in dt_match.Rows)
...{
ListItem li_match = new ListItem();
li_match.Text = dr["HomeTeamCName"].ToString() + " VS " + dr["AwayTeamCname"].ToString() + dr["StartTime"].ToString();
li_match.Value = dr["matchid"].ToString();
MatchID.Items.Add(li_match);
}
}
//在他的SelectedIndexChanged(事件(双击控件即可),取得gameid选择的value为 GamesID.SelectedValue.ToString()
dbconnection conn = new dbconnection();
DataTable dt_game = new DataTable();
string sql_game = "SELECT GamesID,CName,Season,type FROM Games_Info order by Cname";
dt_game = conn.ExecuteSelectTable(sql_game);
ListItem first_Item = new ListItem();
first_Item.Value = "0";
first_Item.Text = "";
GamesID.Items.Add(first_Item);
// MatchID.Items.Add(first_Item);
foreach (DataRow dr in dt_game.Rows)
...{
ListItem li_game = new ListItem();
li_game.Text = dr["CName"].ToString();
li_game.Value = dr["GamesID"].ToString();
GamesID.Items.Add(li_game);
}
方法二
//*****填充nationid(dropdownlist)的选项
string sql = "SELECT * FROM Nations_Info order by CName";
dbconnection conn = new dbconnection();
DataTable dt = new DataTable();
dt = conn.ExecuteSelectTable(sql);
nationid.DataSource = dt.DefaultView;
nationid.DataTextField = "CName"; //dropdownlist的Text的字段
nationid.DataValueField = "NationID";//dropdownlist的Value的字段
nationid.DataBind();
取得他选项的value
protected void GamesID_SelectedIndexChanged(object sender, EventArgs e) ...{
dbconnection conn = new dbconnection();
DataTable dt_match = new DataTable();
string sql_match = "select m.MatchID,t1.CName as HomeTeamCName,t2.CName as AwayTeamCname,m.StartTime from Matchs_Info m inner join Teams_Info t1 on m.HomeTeamID = t1.TeamID inner join Teams_Info t2 on m.AwayTeamID = t2.TeamID where m.flag=3 and m.GamesID= " + GamesID.SelectedValue.ToString() + " order by m.matchid desc";
dt_match = conn.ExecuteSelectTable(sql_match);
foreach (DataRow dr in dt_match.Rows)
...{
ListItem li_match = new ListItem();
li_match.Text = dr["HomeTeamCName"].ToString() + " VS " + dr["AwayTeamCname"].ToString() + dr["StartTime"].ToString();
li_match.Value = dr["matchid"].ToString();
MatchID.Items.Add(li_match);
}
}
//在他的SelectedIndexChanged(事件(双击控件即可),取得gameid选择的value为 GamesID.SelectedValue.ToString()
相关文章推荐
- 如何获取datalist里面子控件(如:dropdownlist)的值[WEB学习示例]
- DropDownList操作;ListBox操作;动态创建控件;Response.Write("欢迎学习ASP.NET''!");
- DropDownList控件学习
- telerik asp.net 控件学习笔记之————ComboBox(DropDownList)
- 20100401 学习笔记:DropDownList等控件添加客户端onchange事件
- 微软的AJAX控件学习一:AccordionDemo
- iOS学习之UIPickerView控件的关联选择
- Bing Maps控件【WP7学习札记之十七】
- swift系统学习控件篇:UIbutton+UIlabel+UITextField+UISwitch+UISlider
- 一步步学习微软InfoPath2010和SP2010--第三章节--表单设计基础:处理InfoPath布局、控件和视图(1)--表单布局
- WPF and Silverlight 学习笔记(十):WPF控件模型
- Asp.net中DetailsView中添加日历控件 及DropDownList 并实现数据同步更新
- mfc学习之路--如何删除通过控件新增的变量
- ASP.NET中的dropdownList控件无法选中项
- MapServer6.4.1教程学习--缩放和漫游控件(2-1)
- 功能: Form窗口最大化时,控件相对位置变化的问题 (学习日记2016-12-23)
- 学习跨线程访问UI控件心得。。
- clisttrl控件学习
- android基础控件学习
- JAVA学习笔记之二控件消息原理