query.aspx页的HTML代码
1<%@ Page language="c#" Codebehind="query.aspx.cs" AutoEventWireup="false" Inherits="XML.query" %>
2<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
3<HTML>
4 <HEAD>
5 <title>query</title>
6 <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
7 <meta content="C#" name="CODE_LANGUAGE">
8 <meta content="JavaScript" name="vs_defaultClientScript">
9 <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
10 </HEAD>
11 <body MS_POSITIONING="GridLayout">
12 <form id="Form1" method="post" runat="server">
13 <FONT face="宋体">
14 <asp:label id="Label7" style="Z-INDEX: 122; LEFT: 264px; POSITION: absolute; TOP: 0px" runat="server"
15 ForeColor="Red" Font-Bold="True" Font-Size="X-Large" BorderStyle="Ridge" BorderWidth="2px"
16 Width="96px">调 查</asp:label></FONT>
17 <TABLE id="Table1" style="Z-INDEX: 102; LEFT: 40px; WIDTH: 560px; POSITION: absolute; TOP: 48px; HEIGHT: 58px"
18 cellSpacing="0" borderColorDark="#0066cc" cellPadding="0" width="560" border="1">
19 <TR>
20 <TD><FONT face="宋体">本例是根据微软广播邵志东老师的一个经典例题改做出来的,主要是实现的是将 DataSet转换成字符串.算是很经典的把复杂问题简单化了.</FONT></TD>
21 </TR>
22 </TABLE>
23 <asp:label id="Label1" style="Z-INDEX: 103; LEFT: 40px; POSITION: absolute; TOP: 144px" runat="server">姓名:</asp:label><asp:textbox id="tbname" style="Z-INDEX: 104; LEFT: 96px; POSITION: absolute; TOP: 144px" runat="server"
24 Width="104px"></asp:textbox><asp:label id="Label2" style="Z-INDEX: 105; LEFT: 256px; POSITION: absolute; TOP: 144px" runat="server">年龄:</asp:label><asp:textbox id="tbnl" style="Z-INDEX: 106; LEFT: 312px; POSITION: absolute; TOP: 144px" runat="server"
25 Width="48px"></asp:textbox><asp:label id="Label3" style="Z-INDEX: 107; LEFT: 408px; POSITION: absolute; TOP: 144px" runat="server">E-mail:</asp:label><asp:textbox id="tbemail" style="Z-INDEX: 108; LEFT: 472px; POSITION: absolute; TOP: 144px" runat="server"
26 Width="128px"></asp:textbox><asp:requiredfieldvalidator id="RequiredFieldValidator1" style="Z-INDEX: 109; LEFT: 96px; POSITION: absolute; TOP: 120px"
27 runat="server" ControlToValidate="tbname" ErrorMessage="必须填写"></asp:requiredfieldvalidator><asp:rangevalidator id="RangeValidator1" style="Z-INDEX: 110; LEFT: 304px; POSITION: absolute; TOP: 120px"
28 runat="server" ControlToValidate="tbnl" ErrorMessage="只能填写数字" Type="Integer" MinimumValue="5" MaximumValue="100"></asp:rangevalidator><asp:regularexpressionvalidator id="RegularExpressionValidator1" style="Z-INDEX: 111; LEFT: 472px; POSITION: absolute; TOP: 120px"
29 runat="server" ControlToValidate="tbemail" ErrorMessage="邮件格式不正确" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:regularexpressionvalidator><asp:label id="q1" style="Z-INDEX: 112; LEFT: 72px; POSITION: absolute; TOP: 192px" runat="server">你是怎么知道洪川医药的?</asp:label><asp:label id="Label4" style="Z-INDEX: 113; LEFT: 24px; POSITION: absolute; TOP: 192px" runat="server">一:</asp:label><asp:radiobuttonlist id="r1" style="Z-INDEX: 114; LEFT: 64px; POSITION: absolute; TOP: 224px" runat="server"
30 Width="536px" RepeatDirection="Horizontal">
31 <asp:ListItem Value="网上搜索得到的">网上搜索得到的</asp:ListItem>
32 <asp:ListItem Value="朋友告诉的">朋友告诉的</asp:ListItem>
33 <asp:ListItem Value="其他方式">其他方式</asp:ListItem>
34 <asp:ListItem Value="现在才知道">现在才知道</asp:ListItem>
35 </asp:radiobuttonlist><asp:label id="Label5" style="Z-INDEX: 115; LEFT: 24px; POSITION: absolute; TOP: 256px" runat="server">二:</asp:label><asp:label id="q2" style="Z-INDEX: 116; LEFT: 72px; POSITION: absolute; TOP: 264px" runat="server">你觉得中国医药黑幕是我们这样的个人能反抗的吗?</asp:label><asp:radiobuttonlist id="r2" style="Z-INDEX: 117; LEFT: 64px; POSITION: absolute; TOP: 296px" runat="server"
36 Width="528px" RepeatDirection="Horizontal">
37 <asp:ListItem Value="要人多齐心">要人多齐心</asp:ListItem>
38 <asp:ListItem Value="没希望">没希望</asp:ListItem>
39 <asp:ListItem Value="有如梦呓">有如梦呓</asp:ListItem>
40 <asp:ListItem Value="绝对可以">绝对可以</asp:ListItem>
41 </asp:radiobuttonlist><asp:label id="Label6" style="Z-INDEX: 118; LEFT: 24px; POSITION: absolute; TOP: 336px" runat="server">三:</asp:label><asp:label id="q3" style="Z-INDEX: 119; LEFT: 72px; POSITION: absolute; TOP: 336px" runat="server">按照你看www.hc115.com这个站能做大吗?</asp:label><asp:radiobuttonlist id="r3" style="Z-INDEX: 120; LEFT: 72px; POSITION: absolute; TOP: 360px" runat="server"
42 Width="520px" RepeatDirection="Horizontal">
43 <asp:ListItem Value="只要坚持,肯定可以">只要坚持,肯定可以</asp:ListItem>
44 <asp:ListItem Value="难与上青天">难与上青天</asp:ListItem>
45 <asp:ListItem Value="无所谓">无所谓</asp:ListItem>
46 <asp:ListItem Value="无聊">无聊</asp:ListItem>
47 </asp:radiobuttonlist><asp:button id="Button1" style="Z-INDEX: 121; LEFT: 96px; POSITION: absolute; TOP: 416px" runat="server"
48 Width="416px" Text="提交调查"></asp:button></form>
49 </body>
50</HTML>
51
1<%@ Page language="c#" Codebehind="query.aspx.cs" AutoEventWireup="false" Inherits="XML.query" %>
2<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
3<HTML>
4 <HEAD>
5 <title>query</title>
6 <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
7 <meta content="C#" name="CODE_LANGUAGE">
8 <meta content="JavaScript" name="vs_defaultClientScript">
9 <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
10 </HEAD>
11 <body MS_POSITIONING="GridLayout">
12 <form id="Form1" method="post" runat="server">
13 <FONT face="宋体">
14 <asp:label id="Label7" style="Z-INDEX: 122; LEFT: 264px; POSITION: absolute; TOP: 0px" runat="server"
15 ForeColor="Red" Font-Bold="True" Font-Size="X-Large" BorderStyle="Ridge" BorderWidth="2px"
16 Width="96px">调 查</asp:label></FONT>
17 <TABLE id="Table1" style="Z-INDEX: 102; LEFT: 40px; WIDTH: 560px; POSITION: absolute; TOP: 48px; HEIGHT: 58px"
18 cellSpacing="0" borderColorDark="#0066cc" cellPadding="0" width="560" border="1">
19 <TR>
20 <TD><FONT face="宋体">本例是根据微软广播邵志东老师的一个经典例题改做出来的,主要是实现的是将 DataSet转换成字符串.算是很经典的把复杂问题简单化了.</FONT></TD>
21 </TR>
22 </TABLE>
23 <asp:label id="Label1" style="Z-INDEX: 103; LEFT: 40px; POSITION: absolute; TOP: 144px" runat="server">姓名:</asp:label><asp:textbox id="tbname" style="Z-INDEX: 104; LEFT: 96px; POSITION: absolute; TOP: 144px" runat="server"
24 Width="104px"></asp:textbox><asp:label id="Label2" style="Z-INDEX: 105; LEFT: 256px; POSITION: absolute; TOP: 144px" runat="server">年龄:</asp:label><asp:textbox id="tbnl" style="Z-INDEX: 106; LEFT: 312px; POSITION: absolute; TOP: 144px" runat="server"
25 Width="48px"></asp:textbox><asp:label id="Label3" style="Z-INDEX: 107; LEFT: 408px; POSITION: absolute; TOP: 144px" runat="server">E-mail:</asp:label><asp:textbox id="tbemail" style="Z-INDEX: 108; LEFT: 472px; POSITION: absolute; TOP: 144px" runat="server"
26 Width="128px"></asp:textbox><asp:requiredfieldvalidator id="RequiredFieldValidator1" style="Z-INDEX: 109; LEFT: 96px; POSITION: absolute; TOP: 120px"
27 runat="server" ControlToValidate="tbname" ErrorMessage="必须填写"></asp:requiredfieldvalidator><asp:rangevalidator id="RangeValidator1" style="Z-INDEX: 110; LEFT: 304px; POSITION: absolute; TOP: 120px"
28 runat="server" ControlToValidate="tbnl" ErrorMessage="只能填写数字" Type="Integer" MinimumValue="5" MaximumValue="100"></asp:rangevalidator><asp:regularexpressionvalidator id="RegularExpressionValidator1" style="Z-INDEX: 111; LEFT: 472px; POSITION: absolute; TOP: 120px"
29 runat="server" ControlToValidate="tbemail" ErrorMessage="邮件格式不正确" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:regularexpressionvalidator><asp:label id="q1" style="Z-INDEX: 112; LEFT: 72px; POSITION: absolute; TOP: 192px" runat="server">你是怎么知道洪川医药的?</asp:label><asp:label id="Label4" style="Z-INDEX: 113; LEFT: 24px; POSITION: absolute; TOP: 192px" runat="server">一:</asp:label><asp:radiobuttonlist id="r1" style="Z-INDEX: 114; LEFT: 64px; POSITION: absolute; TOP: 224px" runat="server"
30 Width="536px" RepeatDirection="Horizontal">
31 <asp:ListItem Value="网上搜索得到的">网上搜索得到的</asp:ListItem>
32 <asp:ListItem Value="朋友告诉的">朋友告诉的</asp:ListItem>
33 <asp:ListItem Value="其他方式">其他方式</asp:ListItem>
34 <asp:ListItem Value="现在才知道">现在才知道</asp:ListItem>
35 </asp:radiobuttonlist><asp:label id="Label5" style="Z-INDEX: 115; LEFT: 24px; POSITION: absolute; TOP: 256px" runat="server">二:</asp:label><asp:label id="q2" style="Z-INDEX: 116; LEFT: 72px; POSITION: absolute; TOP: 264px" runat="server">你觉得中国医药黑幕是我们这样的个人能反抗的吗?</asp:label><asp:radiobuttonlist id="r2" style="Z-INDEX: 117; LEFT: 64px; POSITION: absolute; TOP: 296px" runat="server"
36 Width="528px" RepeatDirection="Horizontal">
37 <asp:ListItem Value="要人多齐心">要人多齐心</asp:ListItem>
38 <asp:ListItem Value="没希望">没希望</asp:ListItem>
39 <asp:ListItem Value="有如梦呓">有如梦呓</asp:ListItem>
40 <asp:ListItem Value="绝对可以">绝对可以</asp:ListItem>
41 </asp:radiobuttonlist><asp:label id="Label6" style="Z-INDEX: 118; LEFT: 24px; POSITION: absolute; TOP: 336px" runat="server">三:</asp:label><asp:label id="q3" style="Z-INDEX: 119; LEFT: 72px; POSITION: absolute; TOP: 336px" runat="server">按照你看www.hc115.com这个站能做大吗?</asp:label><asp:radiobuttonlist id="r3" style="Z-INDEX: 120; LEFT: 72px; POSITION: absolute; TOP: 360px" runat="server"
42 Width="520px" RepeatDirection="Horizontal">
43 <asp:ListItem Value="只要坚持,肯定可以">只要坚持,肯定可以</asp:ListItem>
44 <asp:ListItem Value="难与上青天">难与上青天</asp:ListItem>
45 <asp:ListItem Value="无所谓">无所谓</asp:ListItem>
46 <asp:ListItem Value="无聊">无聊</asp:ListItem>
47 </asp:radiobuttonlist><asp:button id="Button1" style="Z-INDEX: 121; LEFT: 96px; POSITION: absolute; TOP: 416px" runat="server"
48 Width="416px" Text="提交调查"></asp:button></form>
49 </body>
50</HTML>
51
query.aspx页的C#代码
1using System;
2using System.Collections;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Web;
7using System.Web.SessionState;
8using System.Web.UI;
9using System.Web.UI.WebControls;
10using System.Web.UI.HtmlControls;
11using System.IO;
12
13namespace XML
14{
15 /**//// <summary>
16 /// query 的摘要说明。
17 /// 要转载的朋友请写明出处 田洪川,洪川医药-www.hc115.com
18 /// </summary>
19 public class query : System.Web.UI.Page
20 {
21 protected System.Web.UI.WebControls.Label Label1;
22 protected System.Web.UI.WebControls.TextBox tbname;
23 protected System.Web.UI.WebControls.Label Label2;
24 protected System.Web.UI.WebControls.TextBox tbnl;
25 protected System.Web.UI.WebControls.Label Label3;
26 protected System.Web.UI.WebControls.TextBox tbemail;
27 protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
28 protected System.Web.UI.WebControls.RangeValidator RangeValidator1;
29 protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
30 protected System.Web.UI.WebControls.Label q1;
31 protected System.Web.UI.WebControls.Label Label4;
32 protected System.Web.UI.WebControls.RadioButtonList r1;
33 protected System.Web.UI.WebControls.Label Label5;
34 protected System.Web.UI.WebControls.Label q2;
35 protected System.Web.UI.WebControls.RadioButtonList r2;
36 protected System.Web.UI.WebControls.Label Label6;
37 protected System.Web.UI.WebControls.Label q3;
38 protected System.Web.UI.WebControls.RadioButtonList r3;
39 protected System.Web.UI.WebControls.Label Label7;
40 protected System.Web.UI.WebControls.Button Button1;
41
42 private void Page_Load(object sender, System.EventArgs e)
43 {
44 // 在此处放置用户代码以初始化页面
45 }
46
47 Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
48 override protected void OnInit(EventArgs e)
49 {
50 //
51 // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
52 //
53 InitializeComponent();
54 base.OnInit(e);
55 }
56
57 /**//// <summary>
58 /// 设计器支持所需的方法 - 不要使用代码编辑器修改
59 /// 此方法的内容。
60 /// </summary>
61 private void InitializeComponent()
62 {
63 this.Button1.Click += new System.EventHandler(this.Button1_Click);
64 this.Load += new System.EventHandler(this.Page_Load);
65
66 }
67 #endregion
68
69 private void Button1_Click(object sender, System.EventArgs e)
70 {
71 DataSet ads=new DataSet("ads");
72 if(!File.Exists(Server.MapPath("\\xml\\xml\\query.xml")))
73 {//如果文件不存在就创建
74 DataTable adt=new DataTable("query");//创建名字叫query的数据表
75 adt.Columns.Add("id",typeof(int));
76 adt.Columns.Add("name",typeof(string));
77 adt.Columns.Add("nl",typeof(int));
78 adt.Columns.Add("email",typeof(string));
79 adt.Columns.Add("item",typeof(string));
80 ads.Tables.Add(adt);
81 }
82 else
83 {//否则就读取
84 ads.ReadXml(Server.MapPath("\\xml\\xml\\query.xml"));
85 }
86 DataRow adr=ads.Tables[0].NewRow();
87 adr["id"]=ads.Tables[0].Rows.Count+1;//取出数据的最大项加 1,这个方法也算半个小技巧了
88 adr["name"]=this.tbname.Text.Trim();
89 adr["nl"]=this.tbnl.Text;
90 adr["email"]=this.tbemail.Text;
91 //开始子集
92 DataSet bds=new DataSet("item");//建立名字为item的子集
93 DataTable bdt=new DataTable("ditem");//当然有个表还是必要的
94 bds.Tables.Add(bdt);//将表加如到item集中去
95 bdt.Columns.Add("qid",typeof(int));
96 bdt.Columns.Add("qtitle",typeof(string));
97 bdt.Columns.Add("ans",typeof(string));
98
99 for(int i=1;i<=3;i++)//前面我们定制了三个问题,所以就循环三次了,又因为没有q0的控件,所以从一开始循环
100 {
101 DataRow bdr=bds.Tables[0].NewRow();//子表行
102 bdr["qid"]=i;
103 bdr["qtitle"]=((Label)this.FindControl("q"+i.ToString())).Text;
104 RadioButtonList rbl=(RadioButtonList)this.FindControl("r"+i.ToString());//内层循环用与得到答案
105 for(int j=0;j<4;j++)
106 {
107 if(rbl.Items[j].Selected)
108 {
109 bdr["ans"]=rbl.Items[j].Text;
110 }
111 }
112 bdt.Rows.Add(bdr);
113
114 }
115
116 adr["item"]=bds.GetXml();//将item子集以XML存储表现形式格式化存入父表的item项
117 ads.Tables[0].Rows.Add(adr);
118 ads.WriteXml(Server.MapPath("\\xml\\xml\\query.xml"));
119 Session["ads"]=ads;
120 Response.Redirect("query_a.aspx");
121 }
122 }
123}
124
1using System;
2using System.Collections;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Web;
7using System.Web.SessionState;
8using System.Web.UI;
9using System.Web.UI.WebControls;
10using System.Web.UI.HtmlControls;
11using System.IO;
12
13namespace XML
14{
15 /**//// <summary>
16 /// query 的摘要说明。
17 /// 要转载的朋友请写明出处 田洪川,洪川医药-www.hc115.com
18 /// </summary>
19 public class query : System.Web.UI.Page
20 {
21 protected System.Web.UI.WebControls.Label Label1;
22 protected System.Web.UI.WebControls.TextBox tbname;
23 protected System.Web.UI.WebControls.Label Label2;
24 protected System.Web.UI.WebControls.TextBox tbnl;
25 protected System.Web.UI.WebControls.Label Label3;
26 protected System.Web.UI.WebControls.TextBox tbemail;
27 protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
28 protected System.Web.UI.WebControls.RangeValidator RangeValidator1;
29 protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
30 protected System.Web.UI.WebControls.Label q1;
31 protected System.Web.UI.WebControls.Label Label4;
32 protected System.Web.UI.WebControls.RadioButtonList r1;
33 protected System.Web.UI.WebControls.Label Label5;
34 protected System.Web.UI.WebControls.Label q2;
35 protected System.Web.UI.WebControls.RadioButtonList r2;
36 protected System.Web.UI.WebControls.Label Label6;
37 protected System.Web.UI.WebControls.Label q3;
38 protected System.Web.UI.WebControls.RadioButtonList r3;
39 protected System.Web.UI.WebControls.Label Label7;
40 protected System.Web.UI.WebControls.Button Button1;
41
42 private void Page_Load(object sender, System.EventArgs e)
43 {
44 // 在此处放置用户代码以初始化页面
45 }
46
47 Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
48 override protected void OnInit(EventArgs e)
49 {
50 //
51 // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
52 //
53 InitializeComponent();
54 base.OnInit(e);
55 }
56
57 /**//// <summary>
58 /// 设计器支持所需的方法 - 不要使用代码编辑器修改
59 /// 此方法的内容。
60 /// </summary>
61 private void InitializeComponent()
62 {
63 this.Button1.Click += new System.EventHandler(this.Button1_Click);
64 this.Load += new System.EventHandler(this.Page_Load);
65
66 }
67 #endregion
68
69 private void Button1_Click(object sender, System.EventArgs e)
70 {
71 DataSet ads=new DataSet("ads");
72 if(!File.Exists(Server.MapPath("\\xml\\xml\\query.xml")))
73 {//如果文件不存在就创建
74 DataTable adt=new DataTable("query");//创建名字叫query的数据表
75 adt.Columns.Add("id",typeof(int));
76 adt.Columns.Add("name",typeof(string));
77 adt.Columns.Add("nl",typeof(int));
78 adt.Columns.Add("email",typeof(string));
79 adt.Columns.Add("item",typeof(string));
80 ads.Tables.Add(adt);
81 }
82 else
83 {//否则就读取
84 ads.ReadXml(Server.MapPath("\\xml\\xml\\query.xml"));
85 }
86 DataRow adr=ads.Tables[0].NewRow();
87 adr["id"]=ads.Tables[0].Rows.Count+1;//取出数据的最大项加 1,这个方法也算半个小技巧了
88 adr["name"]=this.tbname.Text.Trim();
89 adr["nl"]=this.tbnl.Text;
90 adr["email"]=this.tbemail.Text;
91 //开始子集
92 DataSet bds=new DataSet("item");//建立名字为item的子集
93 DataTable bdt=new DataTable("ditem");//当然有个表还是必要的
94 bds.Tables.Add(bdt);//将表加如到item集中去
95 bdt.Columns.Add("qid",typeof(int));
96 bdt.Columns.Add("qtitle",typeof(string));
97 bdt.Columns.Add("ans",typeof(string));
98
99 for(int i=1;i<=3;i++)//前面我们定制了三个问题,所以就循环三次了,又因为没有q0的控件,所以从一开始循环
100 {
101 DataRow bdr=bds.Tables[0].NewRow();//子表行
102 bdr["qid"]=i;
103 bdr["qtitle"]=((Label)this.FindControl("q"+i.ToString())).Text;
104 RadioButtonList rbl=(RadioButtonList)this.FindControl("r"+i.ToString());//内层循环用与得到答案
105 for(int j=0;j<4;j++)
106 {
107 if(rbl.Items[j].Selected)
108 {
109 bdr["ans"]=rbl.Items[j].Text;
110 }
111 }
112 bdt.Rows.Add(bdr);
113
114 }
115
116 adr["item"]=bds.GetXml();//将item子集以XML存储表现形式格式化存入父表的item项
117 ads.Tables[0].Rows.Add(adr);
118 ads.WriteXml(Server.MapPath("\\xml\\xml\\query.xml"));
119 Session["ads"]=ads;
120 Response.Redirect("query_a.aspx");
121 }
122 }
123}
124
query_a.aspx页的HTML代码
1<%@ Page language="c#" Codebehind="query_a.aspx.cs" AutoEventWireup="false" Inherits="XML.query_a" %>
2<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
3<HTML>
4 <HEAD>
5 <title>query_a</title>
6 <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
7 <meta name="CODE_LANGUAGE" Content="C#">
8 <meta name="vs_defaultClientScript" content="JavaScript">
9 <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
10 </HEAD>
11 <body MS_POSITIONING="GridLayout">
12 <form id="Form1" method="post" runat="server">
13 <FONT face="宋体">
14 <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 72px" runat="server"
15 BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3"
16 AutoGenerateColumns="False" Width="536px">
17 <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#669999"></SelectedItemStyle>
18 <ItemStyle ForeColor="#000066"></ItemStyle>
19 <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#006699"></HeaderStyle>
20 <FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle>
21 <Columns>
22 <asp:BoundColumn DataField="id" HeaderText="调查ID"></asp:BoundColumn>
23 <asp:BoundColumn DataField="name" HeaderText="姓名"></asp:BoundColumn>
24 <asp:BoundColumn DataField="email" HeaderText="邮箱"></asp:BoundColumn>
25 <asp:HyperLinkColumn Text="查看详细" DataNavigateUrlField="id" DataNavigateUrlFormatString="query_b.aspx?id={0}"
26 HeaderText="查看详细"></asp:HyperLinkColumn>
27 </Columns>
28 <PagerStyle HorizontalAlign="Left" ForeColor="#000066" BackColor="White" Mode="NumericPages"></PagerStyle>
29 </asp:DataGrid>
30 <asp:Label id="Label1" style="Z-INDEX: 102; LEFT: 232px; POSITION: absolute; TOP: 16px" runat="server"
31 BorderWidth="2px" BorderStyle="Ridge" Width="136px" ForeColor="Red" Font-Bold="True" Font-Size="X-Large">答卷列表</asp:Label></FONT>
32 </form>
33 </body>
34</HTML>
35
1<%@ Page language="c#" Codebehind="query_a.aspx.cs" AutoEventWireup="false" Inherits="XML.query_a" %>
2<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
3<HTML>
4 <HEAD>
5 <title>query_a</title>
6 <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
7 <meta name="CODE_LANGUAGE" Content="C#">
8 <meta name="vs_defaultClientScript" content="JavaScript">
9 <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
10 </HEAD>
11 <body MS_POSITIONING="GridLayout">
12 <form id="Form1" method="post" runat="server">
13 <FONT face="宋体">
14 <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 72px" runat="server"
15 BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3"
16 AutoGenerateColumns="False" Width="536px">
17 <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#669999"></SelectedItemStyle>
18 <ItemStyle ForeColor="#000066"></ItemStyle>
19 <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#006699"></HeaderStyle>
20 <FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle>
21 <Columns>
22 <asp:BoundColumn DataField="id" HeaderText="调查ID"></asp:BoundColumn>
23 <asp:BoundColumn DataField="name" HeaderText="姓名"></asp:BoundColumn>
24 <asp:BoundColumn DataField="email" HeaderText="邮箱"></asp:BoundColumn>
25 <asp:HyperLinkColumn Text="查看详细" DataNavigateUrlField="id" DataNavigateUrlFormatString="query_b.aspx?id={0}"
26 HeaderText="查看详细"></asp:HyperLinkColumn>
27 </Columns>
28 <PagerStyle HorizontalAlign="Left" ForeColor="#000066" BackColor="White" Mode="NumericPages"></PagerStyle>
29 </asp:DataGrid>
30 <asp:Label id="Label1" style="Z-INDEX: 102; LEFT: 232px; POSITION: absolute; TOP: 16px" runat="server"
31 BorderWidth="2px" BorderStyle="Ridge" Width="136px" ForeColor="Red" Font-Bold="True" Font-Size="X-Large">答卷列表</asp:Label></FONT>
32 </form>
33 </body>
34</HTML>
35
query_a.aspx的C#代码
1using System;
2using System.Collections;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Web;
7using System.Web.SessionState;
8using System.Web.UI;
9using System.Web.UI.WebControls;
10using System.Web.UI.HtmlControls;
11
12namespace XML
13{
14 /**//// <summary>
15 /// query 的摘要说明。
16 /// 要转载的朋友请写明出处 田洪川,洪川医药-www.hc115.com
17 /// </summary>
18 public class query_a : System.Web.UI.Page
19 {
20 protected System.Web.UI.WebControls.Label Label1;
21 protected System.Web.UI.WebControls.DataGrid DataGrid1;
22
23 private void Page_Load(object sender, System.EventArgs e)
24 {
25 // 在此处放置用户代码以初始化页面
26 if(Session["ads"]!=null)
27 {//做这个判断是为了可以直接打开这个页,而不通过答卷来
28 DataSet ds=(DataSet)Session["ads"];
29 DataGrid1.DataSource=ds.Tables[0].DefaultView;
30 DataGrid1.DataBind();
31 }
32 else
33 {
34 DataSet ds=new DataSet();
35 ds.ReadXml(Server.MapPath("\\xml\\xml\\query.xml"));
36 DataGrid1.DataSource=ds.Tables[0].DefaultView;
37 DataGrid1.DataBind();
38 }
39 }
40
41 Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
42 override protected void OnInit(EventArgs e)
43 {
44 //
45 // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
46 //
47 InitializeComponent();
48 base.OnInit(e);
49 }
50
51 /**//// <summary>
52 /// 设计器支持所需的方法 - 不要使用代码编辑器修改
53 /// 此方法的内容。
54 /// </summary>
55 private void InitializeComponent()
56 {
57 this.Load += new System.EventHandler(this.Page_Load);
58
59 }
60 #endregion
61 }
62}
63
1using System;
2using System.Collections;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Web;
7using System.Web.SessionState;
8using System.Web.UI;
9using System.Web.UI.WebControls;
10using System.Web.UI.HtmlControls;
11
12namespace XML
13{
14 /**//// <summary>
15 /// query 的摘要说明。
16 /// 要转载的朋友请写明出处 田洪川,洪川医药-www.hc115.com
17 /// </summary>
18 public class query_a : System.Web.UI.Page
19 {
20 protected System.Web.UI.WebControls.Label Label1;
21 protected System.Web.UI.WebControls.DataGrid DataGrid1;
22
23 private void Page_Load(object sender, System.EventArgs e)
24 {
25 // 在此处放置用户代码以初始化页面
26 if(Session["ads"]!=null)
27 {//做这个判断是为了可以直接打开这个页,而不通过答卷来
28 DataSet ds=(DataSet)Session["ads"];
29 DataGrid1.DataSource=ds.Tables[0].DefaultView;
30 DataGrid1.DataBind();
31 }
32 else
33 {
34 DataSet ds=new DataSet();
35 ds.ReadXml(Server.MapPath("\\xml\\xml\\query.xml"));
36 DataGrid1.DataSource=ds.Tables[0].DefaultView;
37 DataGrid1.DataBind();
38 }
39 }
40
41 Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
42 override protected void OnInit(EventArgs e)
43 {
44 //
45 // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
46 //
47 InitializeComponent();
48 base.OnInit(e);
49 }
50
51 /**//// <summary>
52 /// 设计器支持所需的方法 - 不要使用代码编辑器修改
53 /// 此方法的内容。
54 /// </summary>
55 private void InitializeComponent()
56 {
57 this.Load += new System.EventHandler(this.Page_Load);
58
59 }
60 #endregion
61 }
62}
63
query_b.aspx页的HTML代码
1<%@ Page language="c#" Codebehind="query_b.aspx.cs" AutoEventWireup="false" Inherits="XML.query_b" %>
2<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
3<HTML>
4 <HEAD>
5 <title>query_b</title>
6 <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
7 <meta name="CODE_LANGUAGE" Content="C#">
8 <meta name="vs_defaultClientScript" content="JavaScript">
9 <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
10 </HEAD>
11 <body MS_POSITIONING="GridLayout">
12 <FONT face="宋体"></FONT>
13 <form id="Form1" method="post" runat="server">
14 <FONT face="宋体">
15 <asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 200px; POSITION: absolute; TOP: 8px" runat="server"
16 ForeColor="Red" Font-Bold="True" Font-Size="X-Large" BorderStyle="Ridge" BorderWidth="2px"
17 Width="208px">答卷详细信息</asp:Label>
18 <asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 16px; POSITION: absolute; TOP: 120px"
19 runat="server" BorderStyle="None" BorderWidth="1px" BorderColor="#CC9966" BackColor="White"
20 CellPadding="4" AutoGenerateColumns="False">
21 <SelectedItemStyle Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66"></SelectedItemStyle>
22 <ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle>
23 <HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></HeaderStyle>
24 <FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
25 <Columns>
26 <asp:BoundColumn DataField="qid" HeaderText="题号">
27 <HeaderStyle Width="50px"></HeaderStyle>
28 </asp:BoundColumn>
29 <asp:BoundColumn DataField="qtitle" HeaderText="题目"></asp:BoundColumn>
30 <asp:BoundColumn DataField="ans" HeaderText="答案"></asp:BoundColumn>
31 </Columns>
32 <PagerStyle HorizontalAlign="Center" ForeColor="#330099" BackColor="#FFFFCC"></PagerStyle>
33 </asp:DataGrid>
34 <asp:Label id="Label2" style="Z-INDEX: 103; LEFT: 16px; POSITION: absolute; TOP: 72px" runat="server">答卷人:</asp:Label>
35 <asp:Label id="lblname" style="Z-INDEX: 104; LEFT: 96px; POSITION: absolute; TOP: 72px" runat="server">Label</asp:Label>
36 <asp:Label id="Label3" style="Z-INDEX: 105; LEFT: 232px; POSITION: absolute; TOP: 72px" runat="server">答卷ID:</asp:Label>
37 <asp:Label id="lblid" style="Z-INDEX: 106; LEFT: 312px; POSITION: absolute; TOP: 72px" runat="server">Label</asp:Label></FONT>
38 </form>
39 </body>
40</HTML>
41
1<%@ Page language="c#" Codebehind="query_b.aspx.cs" AutoEventWireup="false" Inherits="XML.query_b" %>
2<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
3<HTML>
4 <HEAD>
5 <title>query_b</title>
6 <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
7 <meta name="CODE_LANGUAGE" Content="C#">
8 <meta name="vs_defaultClientScript" content="JavaScript">
9 <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
10 </HEAD>
11 <body MS_POSITIONING="GridLayout">
12 <FONT face="宋体"></FONT>
13 <form id="Form1" method="post" runat="server">
14 <FONT face="宋体">
15 <asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 200px; POSITION: absolute; TOP: 8px" runat="server"
16 ForeColor="Red" Font-Bold="True" Font-Size="X-Large" BorderStyle="Ridge" BorderWidth="2px"
17 Width="208px">答卷详细信息</asp:Label>
18 <asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 16px; POSITION: absolute; TOP: 120px"
19 runat="server" BorderStyle="None" BorderWidth="1px" BorderColor="#CC9966" BackColor="White"
20 CellPadding="4" AutoGenerateColumns="False">
21 <SelectedItemStyle Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66"></SelectedItemStyle>
22 <ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle>
23 <HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></HeaderStyle>
24 <FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
25 <Columns>
26 <asp:BoundColumn DataField="qid" HeaderText="题号">
27 <HeaderStyle Width="50px"></HeaderStyle>
28 </asp:BoundColumn>
29 <asp:BoundColumn DataField="qtitle" HeaderText="题目"></asp:BoundColumn>
30 <asp:BoundColumn DataField="ans" HeaderText="答案"></asp:BoundColumn>
31 </Columns>
32 <PagerStyle HorizontalAlign="Center" ForeColor="#330099" BackColor="#FFFFCC"></PagerStyle>
33 </asp:DataGrid>
34 <asp:Label id="Label2" style="Z-INDEX: 103; LEFT: 16px; POSITION: absolute; TOP: 72px" runat="server">答卷人:</asp:Label>
35 <asp:Label id="lblname" style="Z-INDEX: 104; LEFT: 96px; POSITION: absolute; TOP: 72px" runat="server">Label</asp:Label>
36 <asp:Label id="Label3" style="Z-INDEX: 105; LEFT: 232px; POSITION: absolute; TOP: 72px" runat="server">答卷ID:</asp:Label>
37 <asp:Label id="lblid" style="Z-INDEX: 106; LEFT: 312px; POSITION: absolute; TOP: 72px" runat="server">Label</asp:Label></FONT>
38 </form>
39 </body>
40</HTML>
41
query_b.aspx页的C#代码
1using System;
2using System.Collections;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Web;
7using System.Web.SessionState;
8using System.Web.UI;
9using System.Web.UI.WebControls;
10using System.Web.UI.HtmlControls;
11using System.IO;
12namespace XML
13{
14 /**//// <summary>
15 /// query 的摘要说明。
16 /// 要转载的朋友请写明出处 田洪川,洪川医药-www.hc115.com
17 /// </summary>
18 public class query_b : System.Web.UI.Page
19 {
20 protected System.Web.UI.WebControls.DataGrid DataGrid1;
21 protected System.Web.UI.WebControls.Label Label2;
22 protected System.Web.UI.WebControls.Label lblname;
23 protected System.Web.UI.WebControls.Label Label3;
24 protected System.Web.UI.WebControls.Label lblid;
25 protected System.Web.UI.WebControls.Label Label1;
26
27 private void Page_Load(object sender, System.EventArgs e)
28 {
29// //使用Get方式得到问卷ID
30// string qid=Request.QueryString["id"];//得到答卷者的ID
31// lblid.Text=qid;
32// //读出XML文件
33// DataSet ads=new DataSet();
34// ads.ReadXml(Server.MapPath("\\xml\\xml\\query.xml"));
35// //利用数组得出结果
36// DataRow[] arr=ads.Tables[0].Select("id="+qid+"");
37// lblname.Text=arr[0]["name"].ToString();
38// string setxml=arr[0]["item"].ToString();
39// //把setxml转化成dataset
40// StringReader sr=new StringReader(setxml);//这个使用了IO命名空间
41// DataSet bds=new DataSet("query");
42// bds.ReadXml(sr);
43// //执行数据绑定
44// this.DataGrid1.DataSource=bds.Tables[0].DefaultView;
45// this.DataGrid1.DataBind();
46 /**//// <summary>
47 /// 以上方法并非唯一,下面这个方法一样可以实现的,呵呵
48 /// </summary>
49 //使用Get方式得到问卷ID
50 string qid=Request.QueryString["id"];//得到答卷者的ID
51 lblid.Text=qid;
52 //读出XML文件
53 DataSet ads=new DataSet();
54 ads.ReadXml(Server.MapPath("\\xml\\xml\\query.xml"));
55 //通过DataView方法实现
56 DataView dv=ads.Tables["query"].DefaultView;
57 dv.RowFilter="id="+qid+"";//这也是筛选数据集中数据的一种好方法
58 lblname.Text=dv[0]["name"].ToString();
59 string setxml=dv[0]["item"].ToString();
60 //把setxml转化成dataset
61 StringReader sr=new StringReader(setxml);//这个使用了IO命名空间
62 DataSet bds=new DataSet("query");
63 bds.ReadXml(sr);
64 //执行数据绑定
65 this.DataGrid1.DataSource=bds.Tables[0].DefaultView;
66 this.DataGrid1.DataBind();
67
68 }
69
70 Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
71 override protected void OnInit(EventArgs e)
72 {
73 //
74 // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
75 //
76 InitializeComponent();
77 base.OnInit(e);
78 }
79
80 /**//// <summary>
81 /// 设计器支持所需的方法 - 不要使用代码编辑器修改
82 /// 此方法的内容。
83 /// </summary>
84 private void InitializeComponent()
85 {
86 this.Load += new System.EventHandler(this.Page_Load);
87
88 }
89 #endregion
90 }
91}
92
1using System;
2using System.Collections;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Web;
7using System.Web.SessionState;
8using System.Web.UI;
9using System.Web.UI.WebControls;
10using System.Web.UI.HtmlControls;
11using System.IO;
12namespace XML
13{
14 /**//// <summary>
15 /// query 的摘要说明。
16 /// 要转载的朋友请写明出处 田洪川,洪川医药-www.hc115.com
17 /// </summary>
18 public class query_b : System.Web.UI.Page
19 {
20 protected System.Web.UI.WebControls.DataGrid DataGrid1;
21 protected System.Web.UI.WebControls.Label Label2;
22 protected System.Web.UI.WebControls.Label lblname;
23 protected System.Web.UI.WebControls.Label Label3;
24 protected System.Web.UI.WebControls.Label lblid;
25 protected System.Web.UI.WebControls.Label Label1;
26
27 private void Page_Load(object sender, System.EventArgs e)
28 {
29// //使用Get方式得到问卷ID
30// string qid=Request.QueryString["id"];//得到答卷者的ID
31// lblid.Text=qid;
32// //读出XML文件
33// DataSet ads=new DataSet();
34// ads.ReadXml(Server.MapPath("\\xml\\xml\\query.xml"));
35// //利用数组得出结果
36// DataRow[] arr=ads.Tables[0].Select("id="+qid+"");
37// lblname.Text=arr[0]["name"].ToString();
38// string setxml=arr[0]["item"].ToString();
39// //把setxml转化成dataset
40// StringReader sr=new StringReader(setxml);//这个使用了IO命名空间
41// DataSet bds=new DataSet("query");
42// bds.ReadXml(sr);
43// //执行数据绑定
44// this.DataGrid1.DataSource=bds.Tables[0].DefaultView;
45// this.DataGrid1.DataBind();
46 /**//// <summary>
47 /// 以上方法并非唯一,下面这个方法一样可以实现的,呵呵
48 /// </summary>
49 //使用Get方式得到问卷ID
50 string qid=Request.QueryString["id"];//得到答卷者的ID
51 lblid.Text=qid;
52 //读出XML文件
53 DataSet ads=new DataSet();
54 ads.ReadXml(Server.MapPath("\\xml\\xml\\query.xml"));
55 //通过DataView方法实现
56 DataView dv=ads.Tables["query"].DefaultView;
57 dv.RowFilter="id="+qid+"";//这也是筛选数据集中数据的一种好方法
58 lblname.Text=dv[0]["name"].ToString();
59 string setxml=dv[0]["item"].ToString();
60 //把setxml转化成dataset
61 StringReader sr=new StringReader(setxml);//这个使用了IO命名空间
62 DataSet bds=new DataSet("query");
63 bds.ReadXml(sr);
64 //执行数据绑定
65 this.DataGrid1.DataSource=bds.Tables[0].DefaultView;
66 this.DataGrid1.DataBind();
67
68 }
69
70 Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
71 override protected void OnInit(EventArgs e)
72 {
73 //
74 // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
75 //
76 InitializeComponent();
77 base.OnInit(e);
78 }
79
80 /**//// <summary>
81 /// 设计器支持所需的方法 - 不要使用代码编辑器修改
82 /// 此方法的内容。
83 /// </summary>
84 private void InitializeComponent()
85 {
86 this.Load += new System.EventHandler(this.Page_Load);
87
88 }
89 #endregion
90 }
91}
92