新建一个页面拷入以下前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Photo.aspx.cs" Inherits="samples_Photo" %>
<!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 runat="server">
<title>Created by 沙加, darkangle.cnblogs.com</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="gv1" runat="server" />
<hr />
<h1>Output : </h1>
<asp:Literal ID="ltOutput" runat="server" />
</div>
</form>
</body>
</html>
后台:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class samples_Photo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataTable dtPhoto = new DataTable();
dtPhoto.Columns.Add("mid");
dtPhoto.Columns.Add("phone_type");
dtPhoto.Columns.Add("name");
DataRow dr = dtPhoto.NewRow();
dr[0] = 223;
dr[1] = "k500";
dr[2] = "sony";
dtPhoto.Rows.Add(dr);
dr = dtPhoto.NewRow();
dr[0] = 224;
dr[1] = "k700";
dr[2] = "sony";
dtPhoto.Rows.Add(dr);
dr = dtPhoto.NewRow();
dr[0] = 235;
dr[1] = "2650";
dr[2] = "nokia";
dtPhoto.Rows.Add(dr);
沙加
|
老鸟四级
|园豆:3680
|
2008-01-28 17:04