Net-informations.com
SiteMap  | About    

How to Asp.Net Dynamic Dataset

The DataSet can be filled either from a data source or dynamically. ADO.NET enables you to create DataTable objects and add them to an existing DataSet.

vb.net
  Dim dt As New DataTable

dataset.Tables.Add(dt)

C#
  DataTable dt = new DataTable();

dataset.Tables.Add(dt);

A DataTable is defined in the System.Data namespace and represents a single table of memory-resident data. You can set constraint information for a DataTable by using the PrimaryKey and Unique properties. The following ASP.NET program create a DataTable dynamically and add it into a Dataset.

Default.aspx

  

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
	<title>Untitled Page</title>
</head>
<body>
	<form id="form1" runat="server">
	<div>
		<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
		<br />
		<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>
	</div>
	</form>
</body>
</html>


Click the following links to see full source code

C# Source Code
VB.NET Source Code
default.aspx.cs
default.aspx.vb





net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.