当前位置: 首页 > news >正文

石岩网站建设 0755建协网官方网站

石岩网站建设 0755,建协网官方网站,芜湖网站建设 文库,做网站的首页下拉列表对于个人#xff08;注册表#xff09;与团队(团队表)#xff08;两张表没有关联#xff09;的展示与可空判断 1#xff0c;在Model中只有GroupId没有名称#xff08;GroupName#xff09;,所以自己定义一个#xff1a; /// summary/// RegistratorMessage 界面… 对于个人注册表与团队(团队表)两张表没有关联的展示与可空判断 1在Model中只有GroupId没有名称GroupName,所以自己定义一个 /// summary/// RegistratorMessage 界面模型类/// /summary[Validator(typeof(RegistratorMessageValidator))]public partial class RegistratorMessageModel : BaseNopEntityModel{/// summary/// RegistratorMessage构造/// /summarypublic RegistratorMessageModel(){}/// summary/// 获取或设置 团队标识/// /summary[NopResourceDisplayName(Admin.RegistratorMessage.GroupId)][UIHint(Int32Nullable)]public Nullableint GroupId { get; set; }/// summary/// 团队标识名称/// /summarypublic string GroupName { get; set; }} 2.在界面view列表展示中 columns: [{field: GroupName,//团队标识名称title: T(Admin.RegistratorMessage.GroupId),width:100,}] 2.1在添加界面呈现方式 div classform-groupdiv classcol-md-3Html.NopLabelFor(model model.GroupId)/divdiv classcol-md-6Html.NopEditorFor(model model.GroupName)//输入框中的值Html.ValidationMessageFor(model model.GroupId)/div/div 3.在服务端控制器中 为了能呈现界面的GroupName ,故需要在控制器中ListInfo方法Create方法Edit方法调用公共方法 public string GroupNameIcon(RegistratorMessageModel model){if (model.GroupId.HasValue)//用0标识不是团队 判断是否可空{if (model.GroupId.Value ! 0)//判断是否为0即个人{model.GroupName _groupRegistratorMessageService.GetGroupRegistratorMessageById(model.GroupId.Value).GroupName;}else{model.GroupName 0;}}else{model.GroupName 0;}return model.GroupName;} 调用方式为GroupNameIconmodel 例如添加方法中 public ActionResult Create(){var model new RegistratorMessageModel();GroupNameIcon(model);//团队标识名称return View(model);} 其余方法与添加方法的使用相同。 4将界面传回来的GroupName通过查询获得GroupId(因为数据库存储的是GroupId,GroupName只是自己定义的为了临时展示用的) 使用方式的方式调用 方法为 private void GroupIdIcon(RegistratorMessageModel model, RegistratorMessage eventInfo){eventInfo.GroupId _groupRegistratorMessageService.GetAllGroupRegistratorMessages().FirstOrDefault(x x.GroupName model.GroupName) ! null ? (_groupRegistratorMessageService.GetAllGroupRegistratorMessages().FirstOrDefault(x x.GroupName model.GroupName).Id) : 0;} 4.1方法的调用为 例子添加界面将输入的GroupName转为数据库可以存放的GroupId [HttpPost, ParameterBasedOnFormName(save-continue, continueEditing)]public ActionResult Create(RegistratorMessageModel model, bool continueEditing){if (ModelState.IsValid){var Info model.ToEntity();GroupIdIcon(model, Info);//获得团队id _registratorMessageService.InsertRegistratorMessage(Info);//插入到数据库 SuccessNotification(_localizationService.GetResource(添加成功));if (continueEditing){return RedirectToAction(Edit, new { id Info.Id });}return RedirectToAction(List);}GroupNameIcon(model);//团队标识名称return View(model);}  上面这种做法有一个问题就是如何在添加或者编辑的时候出现了还没有存在数据库团队名称则列表展示中将不会出现数据。所以不建议才有公共里面的方法   使用这种判断方式先判断在团队存在的是否存在的前提下再在去查询匹配数据库进而判断是否赋值 if (entity.GroupId ! null){var team _groupRegistratorMessageService.GetAllGroupRegistratorMessages().FirstOrDefault(g g.Id entity.GroupId);if (team ! null){model.TeamName team.GroupName;}}   posted on 2017-01-16 13:37 WFaceBoss 阅读(...) 评论(...) 编辑 收藏 转载于:https://www.cnblogs.com/wfaceboss/p/6289321.html
http://www.zqtcl.cn/news/479513/

相关文章:

  • 装饰公司网站开发c 网站开发实例教程
  • 专业层析成像代做网站网站建设收获
  • saas云建站平台源码附近那里有做网站的
  • 网站开发接口成都学校网站建设
  • 商城网站策划火星建站和八亿建站
  • 如何使用模板做网站php精品网站建设
  • 建设一个网站的具体流程职业培训机构需要什么资质
  • 网站怎么做弹幕播放器自助免费网站制作
  • 网站咨询弹窗是怎么做的网站建设的目标客户
  • 搞好姓氏源流网站建设Wordpress 商城主题过于臃肿
  • 如何网站客户案例上海网站备案查询
  • 沈阳大熊网站建设制作北京门户网站制作公司
  • 如何制作自己的网站免费最好的建站平台
  • 自己网站做电子签章有效么网站的规划与建设案例分析
  • 945新开传奇网站深圳动画营销推广的原因
  • 网站制作加盟网站推广 知乎
  • 广西东晋建设有限公司网站电商详情页模板免费套用
  • dedecms 做影网站商丘家居网站建设
  • 七里港网站建设商城购物网站有哪些模块
  • 中英网站怎么做网站域名的作用是什么
  • 网站建设开题报告ppt模板重庆建设工程信息网址
  • 做个什么类型网站百度云资源链接分享群组
  • 商务网站建设的主流程西安建设局网站
  • 邢台营销型网站建设做网站的保证承诺
  • 关于茶叶的网站模板免费下载wordpress多边形按钮
  • 贵阳市网站建设手工制作花
  • 娄底哪里做网站免费永久不限空间
  • 网站标签怎么做wordpress 后台模板
  • 内江移动网站建设网站内部链接的作用有哪些
  • 阿里云的wordpress建站wordpress 批量定时发布