Partial Class DataCollection Inherits System.Web.UI.Page Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click Dim Cart As DataSet = RetrieveCart() Cart = DumpCart(Cart) Dim aRow As DataRow aRow = Cart.Tables(0).NewRow ' Validation here aRow("SID") = StudentID.Text aRow("M") = Mark.Text Cart.Tables(0).Rows.Add(aRow) MarkList.DataSource = Cart.Tables(0) MarkList.DataBind() End Sub Private Function RetrieveCart() As DataSet Dim Cart As New DataSet Dim CartTable As New DataTable CartTable.Columns.Add("SID", GetType(Integer)) CartTable.Columns.Add("M", GetType(Integer)) CartTable.TableName = "CartTable" Cart.Tables.Add(CartTable) Cart.DataSetName = "Cart" Return Cart End Function Private Function DumpCart(ByVal Cart As DataSet) As DataSet If MarkList.Rows.Count > 0 Then Dim NM_TextBox As TextBox Dim aRow As DataRow For Each gRow As GridViewRow In MarkList.Rows aRow = Cart.Tables(0).NewRow aRow(0) = gRow.Cells(0).Text aRow(1) = gRow.Cells(1).Text NM_TextBox = CType(gRow.FindControl("NM"), TextBox) If Not (NM_TextBox Is Nothing) Then If NM_TextBox.Text.Trim.Length > 0 AndAlso IsNumeric(NM_TextBox.Text.Trim) Then aRow(1) = NM_TextBox.Text.Trim Else aRow(1) = gRow.Cells(1).Text FormMessage.Text = "The new mark must be numeric " End If End If Cart.Tables(0).Rows.Add(aRow) Next End If Return Cart End Function Protected Sub btnEdit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEdit.Click Dim Cart As DataSet = RetrieveCart() Cart = DumpCart(Cart) MarkList.DataSource = Cart.Tables(0) MarkList.DataBind() End Sub End Class