您的位置:首页 > 其它

Table控件布局DataList模板

2007-04-28 15:45 369 查看
index.aspx代码如下:

1

3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

4

5<html xmlns="http://www.w3.org/1999/xhtml" >

6<head runat="server">

7 <title>Table控件布局DataList模板</title>

8</head>

9<body>

10 <form id="form1" runat="server">

11 <div align="center">

12 <asp:DataList ID="DataList1" runat="server" Width="365px" BackColor="#FFC080">

13 <ItemTemplate>

14 <table style="width: 390px; height: 71px; font-size: 9pt; background-color: #ffffcc;" align="center" border="1">

15 <tr>

16 <td style="width: 61px; height: 17px">

17 姓      名:</td>

18 <td style="width: 78px; height: 17px">

19 <td style="width: 61px; height: 17px">

21 性      别:</td>

22 <td style="width: 139px; height: 17px;">

23 </tr>

25 <tr>

26 <td style="width: 61px; height: 18px">

27 年      龄:</td>

28 <td style="width: 78px; height: 18px">

29 <td style="width: 61px; height: 18px">

31 出生日期:</td>

32 <td style="width: 139px; height: 18px">

33 </tr>

35 <tr>

36 <td style="width: 61px">

37 政治面貌:</td>

38 <td style="width: 78px">

39 <td style="width: 61px">

41 家庭住址:</td>

42 <td style="width: 139px">

43 </tr>

45 <tr>

46 <td style="width: 61px">

47 联系电话:</td>

48 <td style="width: 78px">

49 <td style="width: 61px">

51      QQ:</td>

52 <td style="width: 139px">

53 </tr>

55 </table>

56 <br />

57 </ItemTemplate>

58 <HeaderTemplate>

59 职员信息

60 </HeaderTemplate>

61 </asp:DataList></div>

62 </form>

63</body>

64</html>

65

index.aspx.cs代码如下:

1using System;

2using System.Data;

3using System.Configuration;

4using System.Web;

5using System.Web.Security;

6using System.Web.UI;

7using System.Web.UI.WebControls;

8using System.Web.UI.WebControls.WebParts;

9using System.Web.UI.HtmlControls;

10using System.Data.SqlClient;

11

12public partial class _Default : System.Web.UI.Page

13{

14 protected void Page_Load(object sender, EventArgs e)

15 {

16 if (!IsPostBack)

17 {

18 string strCon = "Data Source=(local); Database=db_02;Uid=sa;Pwd=123456";

19 SqlConnection sqlcon = new SqlConnection(strCon);

20 string sqlstr = "select top 2* from tb_Employee";

21 SqlDataAdapter myda = new SqlDataAdapter(sqlstr,sqlcon);

22 DataSet myds = new DataSet();

23 sqlcon.Open();

24 myda.Fill(myds);

25 DataList1.DataSource = myds;

26 DataList1.DataBind();

27 sqlcon.Close();

28 }

29 }

30}

31
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: