有没有好的方法将 .NET CheckBoxList 绑定到多对多关系?
我有一个相当简单的 .NET WebForms 对象编辑表单,它的数据绑定到数据库。但是,我现在已经有了一个多对多关系,我也需要在表单中实现它。简而言之,对于这个给定的对象,用户需要能够选择零到多个属性,这些属性存储在不同的数据库表中。还有一个 object2property 表,它映射对象和属性之间的关系。
我最初的想法是我应该使用像 CheckBoxList 这样的东西,但似乎没有任何好的方法可以以任何有意义的方式将其绑定到 object2property 表。我在谷歌上发现了一些半黑客,但似乎没有任何标准方法可以做到这一点。
我这样做是错误的吗?在 .NET Web 表单中实现多对多关系的编辑用户界面的最佳方法是什么?
I've got a fairly simple .NET WebForms object edit form which is databound to a database. However, I've now got a many-to-many relationship that I need to implement in the form as well. In short, for this given object, the user needs to be able to select zero to many properties, which are stored in a different database table. There's also an object2property table which maps the relationships between the objects and the properties.
My initial thought is that I should be using something like a CheckBoxList, but there doesn't seem to be any good way to bind that to the the object2property table in any meaningful way. I've found some half-hacks on google, but there doesn't appear to be any standard way of doing this.
Am I approaching this wrong? What's the best way to implement an edit user interface for a many-to-many relationship in a .NET webform?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我需要做这样的事情,我会使用相同的技术,一个表 object2property 和复选框来让用户选择他们的首选项。
对我来说,这似乎是最干净的方法。
If I need to do something like this, i would use the same technique, one table object2property and checkboxes to let user to chose their preferences.
To me, it seems to be the most clean approach.