很多时候一对多的关系中 只需要显示第一行
最近就遇到这样的情况
客户订单 客户订单行 有可能是分批出货。欠交数量是个总数
客户订单 行 数量 出货数量 出货日期 欠交数量
A 001500 100 2010=05-01 100
A 001500 200 2010=05-02 100
A 001500 100 2010=05-03100
----------------------------------------------------------------
A 001500 100 2010=05-01 100
A 001 200 2010=05-02
A 001 100 2010=05-03
如果在水晶报表中很容易实现,但如果在GRID中呢
其实很简单
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "if(this!=prevselitem){this.style.backgroundColor='#Efefef'}");// 鼠 停留 更改背景色
e.Row.Attributes.Add("onmouseout", "if(this!=prevselitem){this.style.backgroundColor='#ffffff'}");// 鼠 移 原背景色
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
{
currdoc = e.Row.Cells[1].Text.Trim ();
currline = e.Row.Cells[2].Text.Trim ();
if (currdoc == lastdoc && currline == lastline)
{
e.Row.Cells[13].Text = "0";
e.Row.Cells[14].Text = "0";
}
string strprice = e.Row.Cells[13].Text;//取出来的单元格的文本带有RMB字符串,如:<font color=red>RMB</font>50.47
double price = double.Parse(strprice);
if (price > 0)
{
e.Row.Cells[13].Text = "<font color=red>" + e.Row.Cells[13].Text + "</font>";
e.Row.Cells[14].Text = "<font color=red>" + e.Row.Cells[14].Text + "</font>";
// e.Row.BackColor = System.Drawing.Color.Yellow;//使用预设颜色来设置行的背景色
//e.Row.ForeColor = System.Drawing.Color.FromName("#ff0000");//使用十六进制的颜色,设置前景色
}
else
{
e.Row.Cells[13].Text = "";
e.Row.Cells[14].Text = "";
}
}
lastdoc = currdoc;
lastline = currline;
}
}