在c#中编辑动态html表的最佳方法是什么?
通过Access,我能够将一个表(Access表)发布到html表。从数据库到dataTable,再到html表,html表每行包含动态单选按钮 选择单选按钮并按下编辑按钮时,应编辑所选行。最好的方法是什么?我是否应该将选定的htmlRow放置到datatable,然后将datatable发布到列表中 下面是我的代码在c#中编辑动态html表的最佳方法是什么?,c#,html,C#,Html,通过Access,我能够将一个表(Access表)发布到html表。从数据库到dataTable,再到html表,html表每行包含动态单选按钮 选择单选按钮并按下编辑按钮时,应编辑所选行。最好的方法是什么?我是否应该将选定的htmlRow放置到datatable,然后将datatable发布到列表中 下面是我的代码 HtmlTableRow htmlrow=new HtmlTableRow(); htmlrow.Cells.Add(new HtmlTableCell() {InnerText
HtmlTableRow htmlrow=new HtmlTableRow();
htmlrow.Cells.Add(new HtmlTableCell() {InnerText = ""}); // creates an empty cell on row0, column0
//copy headings from datatable
foreach (DataColumn column in datatable.Columns)
{
htmlrow.Cells.Add(new HtmlTableCell() {InnerText = column.ColumnName});
}
//add new row
table1.Rows.Add(htmlrow);
//place values in html table from datatable
foreach (DataRow row in datatable.Rows)
{
htmlrow = new HtmlTableRow();
table1.Rows.Add(htmlrow);
RadioButton rad = new RadioButton();
rad.GroupName = "name"
rad.Attributes.Add("value", row[0].ToString());
//create first cell in a row with radioButton
HtmlTableCell cell = new HtmlTableCell()
htmlrow.Cells.Add(cell);
cell.Controls.Add(rad)
//add cell to the current row with the values from the datatable
for each (DataColumn column in datatable.Columns)
{
htmlrow.Cells.Add(new HtmlTableCell() {InnerText= row[column].ToString()});
}
}
//the current output is a table, with radioButton on its first column.
//the radioButton can only select one, which already works
//i already have an existing EditButton
//code below to be able to edit the html table named table1
编辑html表并将编辑的部分保存回数据库的最佳方法是什么?
按下编辑按钮时,是否应将所选行复制到列表/gridview/etc,以便用户可以编辑?
用户编辑并按下Save后,明智的做法是将数据从list/gridview/etc复制到htmlTable。然后从html表复制回dataTable,以便将数据保存到DB?问题不太清楚。。。你能解释一下你到底在做什么,你需要什么结果吗?我编辑了我的问题,希望这能更好地解释