伴读书童,思比特物流,震动安全套示范图
使用这种方式始终绑定值有问题:
cbxschool.datasource = schoollist;
cbxschool.displaymember = "school_name";
cbxschool.valuemember = "school_id";
选择改变事件获取选中值:cbxschool.selectedvalue 始终是对象,不是想要的id。
解决方法:
if (schoollist != null && schoollist.count > 0)
{
cbxschool.items.clear();
for (int i = 0; i < schoollist.count; i++)
{
cbxschool.items.add(schoollist[i].school_name);
}
//选择默认值
int selectindex = schoollist.findindex(a => a.school_id == schoolid);
cbxschool.selectedindex = selectindex == -1 ? 0 : selectindex;
//获取选中值
string schoolname = schoollist[cbxschool.selectedindex].school_name;
}
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论