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 表名
[解决办法]
两个值是不能合在一起的