DataTable; PostBack; Retain Added Rows
So I have a DataGrid, on the PostBack, i add some rows, then i click a button and the the Page_Load Sub runs, it identifies as "is Post_Back"....how do i retain/retrieve any previously entered rows on a post back? here is my code thus far:
VB Code:
<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not Page.IsPostBack Then
Else
Dim ds As New DataTable
Dim dc1 As New DataColumn("ID", GetType(Integer))
Dim dc2 As New DataColumn("Item", GetType(String))
Dim dc3 As New DataColumn("ItemDescription", GetType(String))
ds.Columns.Add(dc1)
ds.Columns.Add(dc2)
ds.Columns.Add(dc3)
Dim dr As DataRow
dr = ds.NewRow()
dr("ID") = Rnd(3456)
dr("Item") = "John Weidauer"
dr("ItemDescription") = "One handsome devil"
ds.Rows.Add(dr)
DataGrid1.DataSource = ds
DataGrid1.DataBind()
End If
End Sub
</script>
HTML Code:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataGrid runat="server" id="DataGrid1"
HeaderStyle-BackColor="LightGray"
HeaderStyle-Font-Bold="True" />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" UseSubmitBehavior="False" /></div>
</form>
</body>
</html>