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
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
相关文章推荐
- 实现TableLayout布局下循环取出TableRow控件中的文字内容到list集合
- Table布局DataList
- Android控件之TableLayout布局拉伸宽度
- 在DataList、Repeater的HeaderTemplate和FooterTemplate模板中寻找控件FindControl
- datalist的item模板中如何取到添加控件的值
- DataList控件的选择模板,REPEATER控件的模板
- Android:控件布局(表格布局)TableLayout
- 遍历GridView和DataList寻找模板列的控件
- Datalist控件事件使用及调用模板内控件
- REPEATER控件显示数据,交替项显示;分页类的使用,Repeater控件分页;使用DataList控件绑定数据;使用DataList控件的选择模板
- Android UI控件系列:TableLayout(表格布局)
- 地磅称量系统之(30~34)从我定义的界面模板中继承窗体并且完善它的的界面编辑控件布局展示主界面的运行效果图
- 如何:在 DataList Web 服务器控件中动态创建模板
- ASP.net datalist,gridview 编辑模板里面控件的使用;
- 获取列表控件DataList 脚模板上的控件
- Android布局控件之TableLayout
- 遍历GridView和DataList寻找模板列的控件
- C#学习日记2016-12-26 TableLayoutPanel控件以及页面布局
- 达内课程-布局控件之TableLayout和FrameLayout
- [转]在 DataList Web 服务器控件中动态创建模板