collect content from html.table

liunx

Guest
Hi all

Why cant i add some rows to a html table dynamically and then collect content from table and save changes to disc.?

what am i missing in the below code ! :mad:

Thanks




<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Xml" %>
<%@ import Namespace="System.Web.UI" %>
<%@ import Namespace="System.Data" %>
<%@ Page Language="vb" AutoEventWireup="true" Codebehind="WebForm4.aspx.vb" Inherits="Webxml.WebForm4"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm4</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script type="text/javascript">

function insertRow()
{

var newRow=document.getElementById('bordnr').insertRow(0)
var cell0=newRow.insertCell(0)
var cell1=newRow.insertCell(1)

cell0.innerHTML=document.getElementById('txtantal').value;
cell1.innerHTML=document.getElementById('txtn閷眔t').value;

}
</script>
<script runat="server">
Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

Dim DsExit As New DataSet("bordnr")
Dim dt As New DataTable
Dim dv As New DataView(dt)
Dim i As Integer
Dim oHTMLtr As New HtmlTableRow

Dim dr As DataRow


dt.Columns.Add(New DataColumn("BordNumre", GetType(String)))
dt.Columns.Add(New DataColumn("BordNumre1", GetType(String)))
DsExit.Tables.Add(dt)

For Each oHTMLtr In bordnr.Rows


dr = dt.NewRow() ' created new row in the table

dr(0) = oHTMLtr.Cells(0).InnerHtml
dr(1) = oHTMLtr.Cells(1).InnerHtml
dt.Rows.Add(dr)

Next

Dim f As File
If f.Exists(Server.MapPath("XML/Bordstrimmel1.xml")) = True Then
f.Delete(Server.MapPath("XML/Bordstrimmel1.xml"))
End If
DsExit.WriteXml(Server.MapPath("XML/Bordstrimmel1.xml"))


End Sub

</script>
</HEAD>
<body>
<form id="Form1" runat="server">
<TABLE id="bordnr" cellSpacing="4" cellPadding="4" width="41" border="2" runat="server">
</TABLE>
<asp:button id="btnsave" onclick="btnSave_Click" runat="server" Text="save"></asp:button>
</form>
<INPUT id="sl閷硁d" onclick="insertRow(this)" type="button" value="add new"><br>
<INPUT id="txtantal" type="text" value="5"><br>
<INPUT id="txtn閷眔t" type="text" value="5">
</body>
</HTML>I don't think it is possible with the way you are trying to do it. However, you could simulate it by taking the values of each row added, concatenating them into a string, storing the values into a hidden form field, and then making sense of the hidden field's value when the form is posted.

Hope that makes sense.
 
Back
Top