温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:大学生调查投票系统源码
当前文件:
StudentVote/AllVote.aspx.cs,打开代码结构图
StudentVote/AllVote.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using System.Data.SqlClient; 12
13
public partial class AllVote : System.Web.UI.Page 14
{ 15
protected void Page_Load(object sender, EventArgs e) 16
{ 17
18
} 19
20
public string GetList() 21
{ 22
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConStr"]); 23
con.Open(); 24
SqlCommand com = new SqlCommand("select * from tb_Vote ", con); 25
SqlDataReader dr = com.ExecuteReader(); 26
string strBody = "<table width=150 align=center>"; 27
while (dr.Read())//循环读取 28
{ 29
strBody += "<tr><td class=tableBottom>·<a href=vote.aspx?ID=" + dr["ID"] + " >" + dr["Title"].ToString() + "</a></td></tr>\n"; 30
} 31
dr.Close();//关闭阅读器 32
strBody += "</table>"; 33
return strBody; 34
} 35
} 36





}
}