c# - 将用户生成的内容添加到 asp.net 中的数据库

标签 c# javascript asp.net html

在 page_load 中,我创建一个表并用从数据库收集的数据填充它。然后在允许用户修改它之后,我需要对数据库进行更改。但我不知道该怎么做。我环顾四周,现在比开始时更加困惑。我创建表的代码如下所示: delList.Controls.Clear();

            Table tbl = new Table();
            tbl.ID = "tbl1";
            tbl.BorderWidth = 1;
            delList.Controls.Add(tbl);

此代码被添加到占位符中:

    <asp:PlaceHolder ID="delList" runat="server"></asp:PlaceHolder>

我想在页面底部有一个按钮,允许用户选择以保存更改,但我不知道如何执行此操作。主要是因为会有很多行需要更新。我在想使用 javascript 解析表可能是最简单的,然后以某种方式调用一个函数来一次更新数据库一行。但我不确定这是否可能。

我们将不胜感激所有帮助。

最佳答案

如果您使用专门针对此类操作的控件,则会容易得多。我的意思是像 GridView 这样的控件.

GridView displays the values of a data source in a table where each column represents a field and each row represents a record. The GridView control enables you to select, sort, and edit these items.

The GridView control is used to display the values of a data source in a table. Each column represents a field, while each row represents a record. The GridView control supports the following features:

  1. Binding to data source controls, such as SqlDataSource.
  2. Built-in sort capabilities.
  3. Built-in update and delete capabilities.
  4. Built-in paging capabilities.
  5. Built-in row selection capabilities.
  6. Programmatic access to the GridView object model to dynamically set properties, handle events, and so on.
  7. Multiple key fields.
  8. Multiple data fields for the hyperlink columns.
  9. Customizable appearance through themes and styles.

关于c# - 将用户生成的内容添加到 asp.net 中的数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6220517/

相关文章:

c# - 为 .NET 数据访问层使用 MySql 存储过程

c# - 奇怪的控制流程

javascript - React 如何自动一次显示数组中的一个元素

javascript unshift循环弹出

javascript - 从 ClojureScript 调用 JavaScript 对象属性作为构造函数

javascript - 创建 ASP.NET 格式的 JSON 日期

c# - ASP.NET 如何检查文件类型的类型而不考虑扩展名

c# - DLL 中的 SqlConnection 对象在实例化时抛出 "Keyword not supported"异常

c# - 在 Model asp.net c# 中初始化值

c# - 关于 C# 中 Thread.Sleep() 2 小时的问题