投票系统的百分比进度条怎么做? 假如我得到四个选项的票数分别是12 7 3 0,试问怎么用图片搞出每个选项票数的百分比? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 简单的办法:设置tr的背景为你想显示的图片,然后根据 当前票数/总票数 ,算出百分比..增加当前td的宽度就好了. 是呀,td背景图片的width属性=票数百分比:<td width=<>> 用Microsoft Office WebComponent 简称OWC功能很强大 protected System.Web.UI.WebControls.Repeater rVote; public string strA; public string strB; public string strC; public string strD; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 Db.Question myQuestion = new Db.Question(); SqlDataReader dr = myQuestion.drQuestionWhereID(Convert.ToInt32(Request["ID"])); if(dr.Read()) { strA = Convert.ToString(dr.GetInt32(1)/dr.GetInt32(1)+dr.GetInt32(2)+dr.GetInt32(3)+dr.GetInt32(4)); strB = Convert.ToString(dr.GetInt32(2)/dr.GetInt32(1)+dr.GetInt32(2)+dr.GetInt32(3)+dr.GetInt32(4)); strC = Convert.ToString(dr.GetInt32(3)/dr.GetInt32(1)+dr.GetInt32(2)+dr.GetInt32(3)+dr.GetInt32(4)); strD = Convert.ToString(dr.GetInt32(4)/dr.GetInt32(1)+dr.GetInt32(2)+dr.GetInt32(3)+dr.GetInt32(4)); } rVote.DataSource = dr; rVote.DataBind(); }这个计算法是不是错了呀? 背景图片的width属性=“票数百分比” www.dlh21.com中的投票我已经做出来了,但为什么有时候百分比加起来不会刚好等于1呢? public class voteresult : System.Web.UI.Page { protected System.Web.UI.HtmlControls.HtmlTableCell td_vote; protected System.Web.UI.HtmlControls.HtmlTable tab_result; private void Page_Load(object sender, System.EventArgs e)// 在此处放置用户代码以初始化页面 { tab_result=new HtmlTable(); string voteid=Request.Params["voteid"]; string optionid=Request.Params["optionid"]; CommonFunction.SQLConnection scon=new SQLConnection(); System.Data.DataTable dt; System.Web.UI.HtmlControls.HtmlTableCell tc; System.Web.UI.HtmlControls.HtmlTableRow tr; string sql=""; sql="update voteinfo set optioncount=optioncount+1 where voteid="+voteid+" and optionid="+optionid; scon.OperationRecord(sql); sql="select optionstr,optioncount from voteinfo where voteid="+voteid; dt=scon.Query(sql); int i=0; int length=0; while(i<dt.Rows.Count) { if(length<(int)dt.Rows[i].ItemArray[1]) length=(int)dt.Rows[i].ItemArray[1]; i++; } i=0; td_vote.InnerHtml="<table border=\"1\" cellspacing=\"1\" cellpadding=\"1\" align=\"center\">"; while(i<dt.Rows.Count) { td_vote.InnerHtml+="<tr>"; td_vote.InnerHtml+="<td>"; td_vote.InnerHtml+=(string)dt.Rows[i].ItemArray[0]; td_vote.InnerHtml+="</td><td width=\"200\">"; //tc=new HtmlTableCell(); //tr=new HtmlTableRow(); //tc.InnerText= //tr.Cells.Add(tc); //tc=new HtmlTableCell(); td_vote.InnerHtml+="<img src=\"images/long.gif\" width=\""+(((int)dt.Rows[i].ItemArray[1]*100/length)*2)+"\" height=\"9\">"; //tc.InnerHtml= //tr.Cells.Add(tc); td_vote.InnerHtml+="</td><td>"; td_vote.InnerHtml+=((int)dt.Rows[i].ItemArray[1]).ToString();; //tc=new HtmlTableCell(); //tc.InnerText= td_vote.InnerHtml+="</td></tr>"; i++; } td_vote.InnerHtml+="</table>"; }我自己写的一个投票结果显示,其中设定票数最多的那个进度条为100%。 c# 一个面页控制另一面页lable的值 如何动态给页面上的按钮添加点击处理事件? js 客户端取值问题?? 有熟悉ext 的人近来帮下忙 大伙评评,我这算是高效分页吗? 水晶报表该怎么入门?(来者有分) 急求jmail实现 接收和发送 html格式邮件代码 ( vb.net) 旧题新问 高手救我,设为主页和添加到收藏夹的问题 昨天没有解决的问题,关于获取控件的值 asp.net的CSS问题 讨论一下制作WEB打印的问题
<td width=<>>
public string strA;
public string strB;
public string strC;
public string strD;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Db.Question myQuestion = new Db.Question();
SqlDataReader dr = myQuestion.drQuestionWhereID(Convert.ToInt32(Request["ID"]));
if(dr.Read())
{
strA = Convert.ToString(dr.GetInt32(1)/dr.GetInt32(1)+dr.GetInt32(2)+dr.GetInt32(3)+dr.GetInt32(4));
strB = Convert.ToString(dr.GetInt32(2)/dr.GetInt32(1)+dr.GetInt32(2)+dr.GetInt32(3)+dr.GetInt32(4));
strC = Convert.ToString(dr.GetInt32(3)/dr.GetInt32(1)+dr.GetInt32(2)+dr.GetInt32(3)+dr.GetInt32(4));
strD = Convert.ToString(dr.GetInt32(4)/dr.GetInt32(1)+dr.GetInt32(2)+dr.GetInt32(3)+dr.GetInt32(4));
} rVote.DataSource = dr;
rVote.DataBind();
}这个计算法是不是错了呀?
中的投票我已经做出来了,但为什么有时候百分比加起来不会刚好等于1呢?
{
protected System.Web.UI.HtmlControls.HtmlTableCell td_vote;
protected System.Web.UI.HtmlControls.HtmlTable tab_result;
private void Page_Load(object sender, System.EventArgs e)// 在此处放置用户代码以初始化页面
{
tab_result=new HtmlTable();
string voteid=Request.Params["voteid"];
string optionid=Request.Params["optionid"];
CommonFunction.SQLConnection scon=new SQLConnection();
System.Data.DataTable dt;
System.Web.UI.HtmlControls.HtmlTableCell tc;
System.Web.UI.HtmlControls.HtmlTableRow tr;
string sql="";
sql="update voteinfo set optioncount=optioncount+1 where voteid="+voteid+" and optionid="+optionid; scon.OperationRecord(sql);
sql="select optionstr,optioncount from voteinfo where voteid="+voteid; dt=scon.Query(sql);
int i=0;
int length=0;
while(i<dt.Rows.Count)
{
if(length<(int)dt.Rows[i].ItemArray[1])
length=(int)dt.Rows[i].ItemArray[1];
i++;
}
i=0;
td_vote.InnerHtml="<table border=\"1\" cellspacing=\"1\" cellpadding=\"1\" align=\"center\">";
while(i<dt.Rows.Count)
{
td_vote.InnerHtml+="<tr>";
td_vote.InnerHtml+="<td>";
td_vote.InnerHtml+=(string)dt.Rows[i].ItemArray[0];
td_vote.InnerHtml+="</td><td width=\"200\">";
//tc=new HtmlTableCell();
//tr=new HtmlTableRow();
//tc.InnerText=
//tr.Cells.Add(tc);
//tc=new HtmlTableCell();
td_vote.InnerHtml+="<img src=\"images/long.gif\" width=\""+(((int)dt.Rows[i].ItemArray[1]*100/length)*2)+"\" height=\"9\">";
//tc.InnerHtml=
//tr.Cells.Add(tc);
td_vote.InnerHtml+="</td><td>";
td_vote.InnerHtml+=((int)dt.Rows[i].ItemArray[1]).ToString();;
//tc=new HtmlTableCell();
//tc.InnerText=
td_vote.InnerHtml+="</td></tr>";
i++;
}
td_vote.InnerHtml+="</table>";
}我自己写的一个投票结果显示,其中设定票数最多的那个进度条为100%。