Tutorials to .com

Tutorials to .com » Dotnet » Database » Binding Dataview examples (beginners can see, it is simple, but very useful)

Binding Dataview examples (beginners can see, it is simple, but very useful)

Print View , by: iSee ,Total views: 10 ,Word Count: 161 ,Date: Fri, 12 Jun 2009 Time: 8:46 AM

<% @ Page Language = "C #"%>
<% @ Import Namespace = "System.Data"%>
<script Language="C#" Runat="Server">
public void Page_Load (Object src, EventArgs e)
(
int i;
DataTable dt = new DataTable ();
DataRow dr;
dt.Columns.Add (new DataColumn ( "ID"));
dt.Columns.ADD (new datacolumn ( "user name"));
for (i = 1; i <8; i + +)
(
dr = dt.NewRow ();
dr [0] = Int32.ToString (i);
dr [1] = "aspcn" + Int32.ToString (i);
dt.Rows.Add (dr);
)
DG1.DataSource = new DataView (dt);
DG1.DataBind ();

)
</ script>
<html>
<head>
<title> </ title>
</ head>
<body>
<asp:DataGrid id="DG1" runat=server align=center HeaderStyle-BackColor="#aaaadd"/>
</ body>
</ html>


.Net Database Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.