投票系统分享
前几天完成老师的作业,网上投票系统,今天终于做完了,特地把代码分享一下。
第一个页面代码:
1 using 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 ShowVote : System.Web.UI.Page
14 {
15 protected void Page_Load(object sender, EventArgs e)
16 {
17 Bind();
18 }
19 public void Bind()
20 {
21 SqlConnection con = new SqlConnection();
22 con.ConnectionString = " Data Source=.;database=VoteDB;integrated security=true; ";
23 string sql = "select * from votetitle where status=1";
24 SqlDataAdapter sda = new SqlDataAdapter();
25 sda.SelectCommand = new SqlCommand(sql, con);
26 DataSet ds = new DataSet();
27 sda.Fill(ds, "TitleTable");
28 sql = "select * from voteitem where titleid=(select titleid from votetitle where status=1)";
29 sda.SelectCommand = new SqlCommand(sql, con);
30 sda.Fill(ds, "ItemTable");
31 DataView dv = ds.Tables["ItemTable"].DefaultView;
32 dv.Sort = "ItemID asc";
33 string Title = ds.Tables["TitleTable"].Rows[0]["Title"].ToString();
34 Label1.Text = Title;
35 bool Mode = Convert.ToBoolean(ds.Tables["TitleTable"].Rows[0]["Mode"]);
36 HiddenField1.Value = Mode.ToString();
37 if (Mode)
38 {
39 CheckBoxList obj=new CheckBoxList ();
相关新闻>>
- 发表评论
-
- 最新评论 更多>>