使用 ASP.Net 编辑表 - Quick 'n Dirty

发布于 2024-09-04 02:12:51 字数 272 浏览 3 评论 0原文

我需要为用户提供一种在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

開玄 2024-09-11 02:12:51

经过一些研究,我发现最快的方法就是使用 linq to sql 和 GridView。我一直在寻找一种可以轻松集成到现有页面的解决方案。如果没有自动脚手架和生成页面的好处,动态数据有点达不到目标。我想要的 99% 是避免手动编写 SQL 语句和处理 UpdateCommand。

以下是我写的步骤,供我个人参考。它在很大程度上依赖于设计人员,但对于我所需要的,这是完美的:

  1. 新项目(或现有项目)
  2. 将 LinqToSqlClass 文件添加到项目
  3. 将数据源中的相关表添加到设计界面(使用服务器资源管理器)
  4. 构建项目(以便 datacontext 类将生成)
  5. 转到 aspx 页面
  6. 从工具箱中拖动一个 linqdatasource 对象。
  7. 配置数据源(确保在必要时启用更新)
  8. 从工具箱中拖动一个 gridview
  9. 将数据源设置为刚刚创建的 linqdatasource 对象
  10. 必要,自定义列(即,在不可编辑的列上设置只读属性,隐藏不相关的列。)

如有 就动态数据而言,目前缺乏文档。有很多引用早期版本的东西现在的工作方式不太一样。我在此处观看了视频,并按照步骤此处,但当我尝试隐藏不可编辑的列时最终遇到了问题。 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:

  1. New project (or existing project)
  2. Add LinqToSqlClass file to project
  3. Add Relevant tables from datasource to design surface (use server explorer)
  4. Build project (so that datacontext class will get generated)
  5. Go to aspx page
  6. Drag a linqdatasource object from toolbox.
  7. Configure datasource (make sure to enable update if necessary)
  8. Drag a gridview from toolbox
  9. Set datasource to linqdatasource object you just created
  10. Customize columns if necessary (ie, set readonly property on non-editable columns, hide non-relevant columns.)

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!

仄言 2024-09-11 02:12:51

动态数据是通过 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.

清引 2024-09-11 02:12:51

尝试使用 microsoft 的 DynamicData,它内置于 asp.net 4,早期版本可以下载。

Try DynamicData from microsoft, built in to asp.net 4, avalable as download for earlier versions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文