ComboBoxCellType怎样绑定从数据库查询的数据
我绑定了但ComboBoxCellType还是没加载数据表的数据
代码如下:
protected void Page_Load(object sender, EventArgs e)
{
//仪器来源
ComboBoxCellType cmb = new ComboBoxCellType();
DataSet ds =SelectCode();
cmb.DataSource = ds;
cmb.DataMember = "代码名称表";
cmb.DataTextField = "仪器来源";
cmb.DataValueField = "仪器来源";
cmb.UseValue = true;
cmb.ShowEllipsis = true;
cmb.AutoPostBack = true;
SpreadCard.ActiveSheetView.Cells[4, 1].CellType = cmb;
}
public DataSet SelectCode()
{
using (SqlConnection conn=new SqlConnection (DataAccess.ConnString))
{
conn.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from 代码名称表", conn);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
} |