Phi*_*mon 3 c# linq combobox boolean
我遇到了有关数据库和组合框的问题.我有一个表名"站",表内有列,站名和座位.柱座设置为"BIT".我使用组合框为用户选择"是"或"否",但如何将它们转换为BIT并存储到数据库中.这是我创建的代码.
private void btnCreate_Click(object sender, EventArgs e)
{
using (testEntities Setupctx = new testEntities())
{
string[] stations = StationNameList();
station creStation = new station();
creStation.Station1 = txtStation.Text;
creStation.Seat = cbSeats.SelectedItem();
if (stations.Contains(txtStation.Text))
{
MessageBox.Show("This Station is already been created. Please enter a new Station.");
}
else
{
Setupctx.stations.AddObject(creStation);
Setupctx.SaveChanges();
txtStation.Text = "";
cbSeats.SelectedIndex = -1;
MessageBox.Show("New Station Has Been Created.");
}
}
}
Run Code Online (Sandbox Code Playgroud)
错误发生在这里:
creStation.Seat = cbSeats.SelectedItem();
Run Code Online (Sandbox Code Playgroud)
他们提示我无法从字符串转换为bool.有帮助吗?
| 归档时间: |
|
| 查看次数: |
1659 次 |
| 最近记录: |