VoteCount = io.GetVoteCount();
判断下VoteCount的值
判断下VoteCount的值
解决方案 »
- SESSION丢失的问题???
- Server Error in '/' Application.
- 页面引用母版页后JS找不到html标签和服务器控件
- 请教数据采集
- Gridview 固定某列单元格的大小 导出Excell
- DropDownList 的问题,谢谢,在线等
- <a href=".....></a>和<asp:HyperLinkColumn ...DataNavigateUrlFormatString="select_user.aspx?...
- 谁可以帮我做一个类似CSDN的论坛,价钱可详谈
- <asp:HyperLinkColumn>怎么运用Css样式?急
- DataGrid控件中有没有把选择项的按钮风格改变成checkbox或radio?
- 大家帮我看看这个web.config文件错在哪里?
- 投票系统显示不了多投票,不知怎么回事
在试试看!!
最好的解决办法就是把计算好每一行所对应的VoteCount值,把值放进你绑定GridView的数据表里面,然后给Width设置绑定字段。
{
get{return (int)ViewState["VoteCount"];}
set{ViewState["VoteCount"] = value;}
}改用属性 + ViewState处理.楼主应该再看下ASP.NET的运行机制..
//获取总投票数
VoteCount = io.GetVoteCount();这个地方有问题
System.NullReferenceException: 未将对象引用设置到对象的实例。
Label1.Text=VoteView["VoteCount"].ToString();
能运行这两句,结果也是正确的,但是从前台调用后台后就出现了那个问题,未将对象引用到实例,真的不知道会这样,我用Session也出现同样的问题
---------------------------------------
private int VoteCount
{
get{return (int)ViewState["VoteCount"];}
set{ViewState["VoteCount"] = value;}
}private void Page_Load(object sender, System.EventArgs e)
{
ItemOperation io=new ItemOperation();
//获取总投票数
VoteCount = io.GetVoteCount();
}public int FormatVoteCount(String itemCount)
{
return ((Int32.Parse(itemCount) * 100 / VoteCount));
}