现在的GridView的各个单元格里都有数据,相应的Footer里也有所有的汇总数据,现在想根据每个单元格的数据,占汇总数据的百分比,设置此单元格的背景色或图片比如说某单元格的数据是30,汇总数据是100,想达到的效果是这个单元格的背景色只填充30%,可不可以做到背景色只填充30%的宽度,或者用背景图片只拉伸这个单元格宽度的30%请问怎么做到,在线求结果啊!
解决方案 »
- 谁弄过dznt
- 在wap中在不用session,cookie的情况下怎么实现登录?
- 急,急,select @@identity 问题
- 若干年没来,技术排名还没过千阿?撒分,都来接!
- 在winXP环境下用vs2003开发的网站程序在IIS下运行正常,而拿到win 2003的IIS下就无法正常运行,Why?
- 请教 System.Data.OleDb.OleDbException: 语法错误 (操作符丢失)这个错误。
- 不什么原因在aspx页面中的textarea控件里输入特殊字符后__doPostBack执行不了?
- 大家有没有.NET SqlServer的数据访问层啊
- 请问如何把两列合并成一列
- 在datagrid中嵌入了checkbox,我想在datagrid1_editcommand事件中实现改变checkbox绑定的字段?如何实现?
- 关于数据库的一个问题
- 在b/s程序中如何实现双屏显示
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[6].Text == "0")
{
e.Row.Cells[6].Text = "未处理";
}
else if (e.Row.Cells[6].Text == "1")
{
e.Row.Cells[6].Text = "已处理";
e.Row.Cells[6].ForeColor = System.Drawing.Color.Red;
}
if (e.Row.Cells[7].Text == "False")
{
e.Row.Cells[7].Text = "未复核";
((Button)e.Row.Cells[7].FindControl("btn_check")).CommandName = "check";
((Button)e.Row.Cells[7].FindControl("btn_check")).Text = "复核";
}
else if (e.Row.Cells[7].Text == "True")
{
e.Row.Cells[7].Text = "已复核";
((Button)e.Row.Cells[7].FindControl("btn_check")).CommandName = "uncheck";
((Button)e.Row.Cells[7].FindControl("btn_check")).Text = "反复核";
e.Row.Cells[7].ForeColor = System.Drawing.Color.Red;
}
}
http://www.cnblogs.com/insus/archive/2012/04/01/2429442.html
对,类似于这种效果,可是怎么动态应用到gridview里呢
概要代码:
RowDataBound事件:
Label lbInfo = new Lable();
lbInfo.width=运算的百分比取得的宽度。
lbInfo.color=red;
e.Controls.Add(btnuser);
...
http://www.cnblogs.com/insus/archive/2012/10/24/2737483.html由于没有相关测试环境,Insus.NET只能提供相关的方法.
有问题可以再讨论。
下面例子,也是在sql成生好的,在GridView显示即可。
http://www.cnblogs.com/insus/archive/2010/12/28/1918684.html
jquery不是很熟,有没有大神指点下!
如果我想把 这个百分比的效果加进来,请问应该怎么做啊?
$(function () {
var col = $('#GridView1 td:nth-child(1):not(:last)'); // 选择单元格,比如第一列但除了最后一格总计, 单元格中必须是数字
var total = $('#GridView1 td:nth-child(1):last').text(); // 总计数,比如第一列最后一格
col.each(function () {
$(this).css({ width:'100px', textAlign:'center', position:'relative'})
.append('<div style="background:red; position:absolute; top:0; height:100%; width:'
+ $(this).text() / total * 100 + '%;"/>');
});
});