我想在 GridView 页脚的标签上显示名为“total”的列中的值。
“总计”列的值在每一行都是相同的,因此只要我们在该列中,选择哪个单元格都没有关系。
我正在为我的列“总计”使用模板字段,并通过使其可见性 = false 来隐藏它。所以我想要的是我想将名为 total 的列中的值显示到我的 gridview 内的标签上
这是我尝试过的代码示例,但它给出了一个错误:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
int total;
if (e.Row.RowType == DataControlRowType.DataRow)
{
total = Convert.ToInt32(((DataRowView)e.Row.DataItem)["total"].ToString());
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lblamount7 = (Label)e.Row.FindControl("Label27");
lblamount7.Text =total.ToString(); // use of unassigned local variable 'total'
}
}
这是隐藏列的aspx '> '>