投票系统分享
前几天完成老师的作业,网上投票系统,今天终于做完了,特地把代码分享一下。
第一个页面代码:
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 ();
相关新闻>>
- 发表评论
-
- 最新评论 进入详细评论页>>
今日头条
更多>>您可能感兴趣的文章
- MVC3+Entity Framework 实现投票系统(二)
- asp.net DataTable和Dataset序列化成Json格式
- .NET设计模式:工厂方法模式(Factory Method)[1]
- Web Service学习笔记(4)
- 使用ASP.NET MVC3+EF+Jquery制作文字直播系统(四
- .net架构的最后思考(箴言)
- JQuery+Asp.net MVC实现用户名重名查询
- 聊聊.net程序设计——浅谈使用VS2010建模拓展(下
- .NET简谈互操作(四:基础知识之Dispose非托管内存
- Spring MVC 3.0.5+Spring 3.0.5+MyBatis3.0.4全注



