如何使用
后面的代码在网格视图页脚中显示多行信息例如
protected void gridinvoice_RowDataBound(object sender, GridViewRowEventArgs e)
{
decimal Amount = 0;
for (int y = 0; y < gridinvoice.Rows.Count; y++)
{
Amount += Convert.ToDecimal(gridinvoice.Rows[y].Cells[4].Text);
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[3].Text = "Amount";
e.Row.Cells[4].Text = Amount.ToString();
}
}
如何在页脚中添加运费和总金额
def get_host_regex(self, spider):
"""Override this method to implement a different offsite policy"""
allowed_domains = getattr(spider, 'allowed_domains', None)
if not allowed_domains:
return re.compile('') # allow all by default
regex = r'^(.*\.)?(%s)$' % '|'.join(re.escape(d) for d in allowed_domains if d is not None)
return re.compile(regex)
def spider_opened(self, spider):
self.host_regex = self.get_host_regex(spider)
self.domains_seen = set()
答案 0 :(得分:1)
根据您的要求,您可以尝试这样:
protected void gridinvoice_RowDataBound(object sender, GridViewRowEventArgs e)
{
decimal Amount = 0;
for (int y = 0; y < gridinvoice.Rows.Count; y++)
{
Amount += Convert.ToDecimal(gridinvoice.Rows[y].Cells[4].Text);
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[3].Text = "Amount: <br/> Shipping Cost: <br/> Total Amount:";
e.Row.Cells[4].Text = Amount.ToString() +"<br/>"+shipping.ToString() +"<br/>" + total.ToString();
}
}
或者您可以使用控件和页脚模板在Aspx页面上构建页脚,并将值分配给后面代码的控件。
protected void gridinvoice_RowDataBound(object sender, GridViewRowEventArgs e)
{
decimal Amount = 0;
for (int y = 0; y < gridinvoice.Rows.Count; y++)
{
Amount += Convert.ToDecimal(gridinvoice.Rows[y].Cells[4].Text);
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lblamount = e.Row.FindControl("lblid") as Label;
lblam.Text = Amount.ToString();
}
}