我应该使用 ListView、DetailsView 还是 GridView?
我需要显示一个包含各种信息(名称、日期、序列号、注释)的表格。另外,有一个字段需要是三个指定值(Raise、Lower、Release)之一。什么视图是最好/最容易实现的,它可以让我添加/编辑/删除条目,并为“升高”、“降低”、“释放”选项提供下拉选项?
提前致谢!
I need to display a table with various info (names, dates, serial numbers, notes). In addition, there is one field I need to be one of three specified values (Raise, Lower, Release). What view would be the best/easiest to implement which would let me add/edit/delete entries as well as provide a drop down option for the Raise, Lower, Release options?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
他们所有人都可以做到这一点。如果我只想在直列和行中显示数据,我会使用DetailsView 和GridView。详细信息视图每页显示 1 条记录,让您可以做您想做的一切。我个人用它来编辑和插入。我用于显示和删除的 GridView。
当您想要显示奇特的数据时,您可以使用 ListView 和 FormView,这些数据不适合整齐的行和列,而是更复杂的视图。它们也允许您编辑/插入/删除。
要在 DetailsView 和 GridView 中显示 DropDownList,请将 DataBoundField 转换为 TemplateField。
All of them can do that. I use a DetailsView and GridView if i just want to display data that in straight columns and rows. The DetailsView shows 1 record per page and let's you do all you want. I personally use it for Edit and Insert. The GridView i use for Showing and Deleting.
The ListView and FormView you use when you want show fancy data that doesn't let itself fit in neat rows and columns but more complex views. They too let you Edit/Insert/Delete.
To show a DropDownList in the DetailsView and GridView you convert a DataBoundField into a TemplateField.
听起来 GridView 就是您所追求的,您希望能够添加/编辑/删除,并且您可能会在 GridView 中的行中使用 DetailsView (可能对您有用,也可能没有用,但对于添加新记录,您可能会希望它与 GridView 协调),ListView 对于我的想法来说太简单了。
您的列需要一个 TemplateField,其中还包含这三个特定值的下拉选项。
Sounds like a GridView is what your after, you want the ability to add/edit/delete and you might make use of DetailsView from your rows in the GridView (may or may not be useful to you but for adding new records you'll probably want it in coordination with the GridView), the ListView would be too simplistic for what your after I think.
You'll need a TemplateField for your column that has the drop down options for those three specific values as well.
根据您正在做的事情(IE,这是集成到更大的项目还是更多的独立页面中),您可能需要查看动态数据内容。您可以将其指向您的数据库,它将生成提供数据编辑界面所需的所有内容,包括外键/查找表值的下拉列表。
它还提供扩展点来执行您可能需要的任何类型的验证/业务逻辑实施。
Depending on what you're doing (IE, is this integrated into a larger project or more of a standalone page), you might want to look at the Dynamic Data stuff. You can point it at your database and it will generate everything required to provide an editing interface on the data, including dropdowns for foreign key/lookup table values.
It also provides extension points do any kind of validation/business logic enforcement you might need.