📄 vote.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{//显示投票标题
string sql_title = "select voteTitle from voteMaster where voteID=" + Convert.ToInt32(Application["voteID"]);
DataTable dt_table =db.select(sql_title);
Label1.Text=dt_table.Rows[0][0].ToString();
//显示投票项目内容
string sql_details = "select * from voteDetails,voteMaster where voteTitle='" + Label1.Text + "' and voteMaster.voteID=voteDetails.voteID";
DataTable dt_details=db.select(sql_details);
RadioButtonList1.DataSource=dt_details;
RadioButtonList1.DataTextField="voteItem";
RadioButtonList1.DataValueField="voteDetailsID";
RadioButtonList1.DataBind();
}
}
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
string sql = "update voteDetails set voteNum=voteNum+1 where voteDetailsID=" + RadioButtonList1.SelectedValue;
db.execsql(sql);
string sql2 = "update voteMaster set voteSum=voteSum+1 where voteID=" + Convert.ToInt32(Application["voteID"]);
db.execsql(sql2);
Label2.Text = "投票成功,谢谢参与!";
}
catch
{
Label2.Text = "投票失败,再来一次!";
}
}
protected void Button2_Click(object sender, EventArgs e)
{
string voteID = Application["voteID"].ToString();
Response.Redirect("chakan.aspx?voteID=" + voteID);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -