使用 ASP.Net 编辑表 - Quick 'n Dirty
我需要为用户提供一种在 ASP.Net 中编辑表的方法。这些表很简单(没有主/从关系),但可能有很多。即使考虑商业选项(但不是 Iron Speed Designer。那东西对于我的需要来说贵得离谱),为表格提供查看/编辑界面的最快/最简单的方法是什么?
在最简单/理想的配置中,我想将一个控件指向桌子并完成。我研究过一些 ORM 解决方案,但它们都试图成为一把瑞士军刀,只会增加复杂性,而且往往本身就是野兽。
有什么非常简单的东西可以帮助我吗?或者我应该深入研究 SubSonic 或类似的东西?
I have need to provide a way for users to edit tables in ASP.Net. The tables are simple (no master/detail relationships), but there are likely to be a lot of them. What's the quickest/simplest way to provide a view/edit interface to a table, even considering commercial options (but not Iron Speed Designer. That thing is ridiculously expensive for what I need)?
In its most simple/ideal configuration, I'd want to point a control at a table and be done. I've looked at a few ORM solutions, but they all try to be a swiss army knife which just piles on the complexity and tend to be beasts unto themselves.
Is there something that is crazy simple that can help me here? Or should I just dive into SubSonic or something similar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
经过一些研究,我发现最快的方法就是使用 linq to sql 和 GridView。我一直在寻找一种可以轻松集成到现有页面的解决方案。如果没有自动脚手架和生成页面的好处,动态数据有点达不到目标。我想要的 99% 是避免手动编写 SQL 语句和处理 UpdateCommand。
以下是我写的步骤,供我个人参考。它在很大程度上依赖于设计人员,但对于我所需要的,这是完美的:
如有 就动态数据而言,目前缺乏文档。有很多引用早期版本的东西现在的工作方式不太一样。我在此处观看了视频,并按照步骤此处,但当我尝试隐藏不可编辑的列时最终遇到了问题。 linq 生成的更新语句没有引用主键,我得到了 行未找到或更改错误。我放弃了并使用上面的解决方案。
希望这对将来的其他人有帮助!
After some research, the quickest thing I found turns out to be just using linq to sql with a GridView. I was looking for a solution that can easily integrate into existing pages. Without the benefit of auto-scaffolding and generated pages, Dynamic Data kinda misses the mark. 99% of what I wanted was to avoid getting into writing SQL statements and handling the UpdateCommands manually.
Here are the steps I wrote up for my own personal reference. It relies heavily on the designers, but for what I need, this is perfect:
As far as dynamic data is concerned, the documentation is currently lacking. There's a LOT of stuff that references earlier versions that doesn't work quite the same now. I watched the videos here and followed the steps here, but ultimately ran into problems when I tried hiding non-editable columns. The update statement generated by linq didn't reference the primary key and I got the Row not found or changed error. I gave up and used the solution above.
Hope this helps someone else in the future!
动态数据是通过 ASP.Net 编辑数据库表的一种非常简单的方法。我对此一无所知,但我建立了一个网站,使用 Scott Guthrie 的博客文章。它也处理我拥有的简单外键关系。
Dynamic Data is a very easy way to edit database tables via ASP.Net. I had absolutely no knowledge of it, but I set up a website to edit a small database in literally 5 minutes, using one of Scott Guthrie's blog posts. It handled the simple foreign key relationships I had as well.
尝试使用 microsoft 的 DynamicData,它内置于 asp.net 4,早期版本可以下载。
Try DynamicData from microsoft, built in to asp.net 4, avalable as download for earlier versions.
这是有关如何使用标准 ASP.NET Gridview 执行此操作的教程。
Here's a tutorial on how to do it using a standard ASP.NET Gridview.