Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在asp.net中从html表向数据库插入数据_C#_Asp.net_Html - Fatal编程技术网

C# 如何在asp.net中从html表向数据库插入数据

C# 如何在asp.net中从html表向数据库插入数据,c#,asp.net,html,C#,Asp.net,Html,如何将数据从HTML表添加到数据库中 我的桌子是这样的: html += "<table>"; html += "<tr><th>" + "A" + "</th><th>" + "B" + "</th><th>" + "C" + </th></tr>"; html += "<tr><td>" + "0" + "</td><td>" + "1"

如何将数据从HTML表添加到数据库中

我的桌子是这样的:

html += "<table>";
html += "<tr><th>" + "A" + "</th><th>" + "B" + "</th><th>" + "C" + </th></tr>";
html += "<tr><td>" + "0" + "</td><td>" + "1" + "</td><td>" + "2" + </td></tr>";
html += "</table>";
html+=”;
html++=“A”++“B”++“C”+;
html++=“0”++“1”++“2”+;
html+=“”;

我从服务器端调用HTML。

如果您喜欢纯HTML,可以使用类似Knockout.js的JavaScript框架。js允许您使用JavaScript视图模型将数据注入HTML。单击按钮可以指定给视图模型中的JavaScript函数。JavaScript函数可以通过AJAX post调用服务器端的控制器操作方法,从而将数据插入数据库


有关敲除的详细信息,请选中使用System.Text.RegularExpressions(Regex)搜索模式以替换表标记:

替换为空白

替换为
^^^~~~~~~~~~^
表示结束行

替换为
| ^^^^^^^^ ^ ^ ^ ^ ^ ^ ^ ^
表示delimeters

string html = // your html table goes here
string[] lines = html.Split(new string[] { "^^~~~~~~~~~~^^" }, StringSplitOptions.None);
// now your html table is divided into lines, which means rows

// lines[0] = // the header
// lines[1] = // row 1
// lines[2] = // row 2
// lines[3] = // row 3
// ...
// ...

// line 1 is the header/column name
string[] columns = lines[0].Split(new string[] { "||^^^^^^^^^||" }, StringSplitOptions.None);

// columns[0] = // 1st column name
// columns[1] = // 2nd column name
// columns[2] = // 3rd column name
// ...
// ...

for (int i = 1; i < lines.Length; i++)
{
    string[] data = lines[i].Split(new string[] { "||^^^^^^^^^||" }, StringSplitOptions.None);
    // data[0] = // 1st data
    // data[1] = // 2nd data
    // data[2] = // 3rd data 
    // ...  
    // ...
}
string html=//您的html表位于此处
string[]line=html.Split(新字符串[]{“^^~~~~~~~~~~^^”},StringSplitOptions.None);
//现在您的html表被分成了行,这意味着行
//行[0]=//头
//行[1]=//第1行
//行[2]=//第2行
//行[3]=//第3行
// ...
// ...
//第1行是标题/列名
字符串[]列=行[0]。拆分(新字符串[]{“| | ^^^^^^^^^^ | |“},StringSplitOptions.None);
//列[0]=//第一列名称
//列[1]=//第二列名称
//列[2]=//第三列名称
// ...
// ...
对于(int i=1;i
你说的“我从服务器端调用HTML”是什么意思?您是否从服务器端创建此html?请提供更多详细信息我在.cs页面中编写了上述代码