如何在网格中建立2列的总和并在第三列中显示结果? [英] How to make sum of 2 columns in grid and display the result in third column?
本文介绍了如何在网格中建立2列的总和并在第三列中显示结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何显示前两列的总和并在第三列显示结果?
How to display the sum of previous two columns and show the result in third column?"
推荐答案
<asp:GridView runat="server" ID="GV" OnRowDataBound="test_rodatbond">
<Columns>
<asp:BoundField DataField="v1" />
<asp:BoundField DataField="v2" />
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lbl" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
和代码隐藏
and at codebehind
protected void test_rodatbond(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lbl = (Label)e.Row.FindControl("lbl");
lbl.Text = GV.Rows[e.Row.RowIndex].Cells[0].Text + GV.Rows[e.Row.RowIndex].Cells[1].Text;
}
}
这篇关于如何在网格中建立2列的总和并在第三列中显示结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文