日期:2014-05-19  浏览次数:20597 次

DropDownList问题,解决立刻给分
1.怎样绑定两个字段的值

2.绑定后怎样默认选项

------解决方案--------------------
private void Page_Load(object sender, System.EventArgs e)
{
if (! IsPostBack )
{
SqlConnection cn = new SqlConnection( "Server=.;uid=sa;pwd=sa;Database=Pubs " );
SqlCommand cmd = new SqlCommand( "Select au_id, au_lname From Authors ", cn );
cn.Open();
dropAuthors.DataSource = cmd.ExecuteReader();
dropAuthors.DataTextField = "au_lname ";
dropAuthors.DataValueField = "au_id ";
dropAuthors.DataBind();
dropAuthors.SelectedIndex = 2;
cn.Close();
}
}
------解决方案--------------------
2.select (convert(char(10),au_id)+au_lname) as namestring from 表名
------解决方案--------------------
两个值是不能合在一起的