GridView绑定固定行列的空数据以及加入页尾
来源:互联网 发布:三国杀ol淘宝买银两 编辑:程序博客网 时间:2024/05/19 07:43
public void BindNullGV(GridView gv,int rcount,int ccount)
{
DataTable dt = new DataTable("test");
for (int j = 0; j < ccount; j++)
{
string cname = "C" + j.ToString();
DataColumn col = new DataColumn(cname, typeof(decimal));
dt.Columns.Add(col);
}
DataRow row;
for (int i = 0; i < rcount; i++)
{
row = dt.NewRow();
for (int c = 0; c < ccount; c++)
{
row[c] = c + 1;
}
dt.Rows.Add(row);
}
gv.DataSource = dt;
gv.DataBind();
}
protected void gvInfor_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[6].Text = "Total:";
e.Row.Cells[6].HorizontalAlign = HorizontalAlign.Right;
e.Row.Cells[7].Text = rsn.ReturnTotal(7, gvInfor, "1").ToString();
e.Row.Cells[9].Text = rsn.ReturnTotal(9, gvInfor, "1").ToString();
}
}
public decimal ReturnTotal(int col, GridView gv,string status)
{
decimal char_total = 0;
string strqty = null;
int textid = 0;
foreach (GridViewRow gvr in gv.Rows)
{
if (status == "1")
{
textid = col + 1;
if (null != ((TextBox)gvr.Cells[col].FindControl("TextBox" + "" + textid.ToString() + "")).Text.Trim())
{
if ("" == ((TextBox)gvr.Cells[col].FindControl("TextBox" + "" + textid.ToString() + "")).Text.Trim())
{
strqty = "0";
}
else
{
strqty = ((TextBox)gvr.Cells[col].FindControl("TextBox" + "" + textid.ToString() + "")).Text.Trim();
}
char_total += Convert.ToDecimal(strqty);
}
}
else
{
if (null != gvr.Cells[col].Text.ToString())
{
if ("" == gvr.Cells[col].Text.Trim())
{
strqty = "0";
}
else
{
strqty = gvr.Cells[col].Text.Trim();
}
char_total += Convert.ToDecimal(strqty);
}
}
}
return char_total;
}
- GridView绑定固定行列的空数据以及加入页尾
- 无数据GridView绑定空表头1
- GridView 的数据绑定
- GridView的清空数据
- GridView的清空数据
- GridView数据绑定的顺序
- GridView绑定数据的方法
- gridview 绑定数据为空时,表头部分内容显示的解决方法
- 通过gridview.DataSouce=ds绑定数据时GridViewDeleteEventArgs e 的key为空
- 加入程序员的行列
- gridview数据绑定为空时显示提示
- 绑定数据截取固定的字符长度
- 在DataGridView绑定固定列的数据
- DataGrid绑定数据固定的小数位数
- flexigrid 绑定事件process以及对行列的操作
- GridView 使用 DropDownList 出现绑定空值的异常处理
- Gridview空数据的时候显示表头
- Gridview空数据的时候显示表头
- List of Scientist`s Names
- 合上More Exceptional C++的瞬间
- 对代码重构的理解
- 资源文件的引用方法-记号
- 来CSDN了
- GridView绑定固定行列的空数据以及加入页尾
- 测试2
- 办公装修的项目
- 捕获锁表异常
- Microsoft Silverlight 4 正式发布
- 子窗口获取父页面对象
- 浅谈2D游戏开发,面向C++初学者
- 谁帮忙找一个多分类的分类器呀
- servlet跳转页面的几种方法