网格视图显示 [英] Gridview Display

查看:50
本文介绍了网格视图显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,
在我的gridview中,所有字段均为黑色.
我必须显示产品的实际和估计成本.
如果实际成本不超过估算成本.我必须用红色显示该实际成本颜色.

我对此没有任何帮助.

谢谢,


In my gridview all fields in black.
I have to display in that actual and estimated cost of products.
if there at all actual cost cross the estimated cost. I have to display that actual cost color in red.

I don''t have any idea about this help me please.

Thanks,

推荐答案

谢谢您的提问.为此使用项目数据绑定.就像下面的代码.

Thank you for your question. Use Item Data Bound for this. Like bellow code.

<asp:DataGrid id="ItemsGrid" runat="server"

     BorderColor="black"

     BorderWidth="1"

     CellPadding="3"

     ShowFooter="true"

     OnItemDataBound="Item_Bound"

   <HeaderStyle BackColor="#00aaaa">
   </HeaderStyle>
   <FooterStyle BackColor="#00aaaa">
   </FooterStyle>
</asp:DataGrid>









void Item_Bound(Object sender, DataGridItemEventArgs e)
{
   //Label1.Text = Label1.Text + " " + e.Item.ItemIndex;
   // Your code here for Make Red to Product Cost Cell;

}




谢谢,
Mamun




Thanks,
Mamun


有一个叫做gridview的Rowdatabound的事件.每行都会触发该事件.您可以在此处访问该行的每个单元格,并可以根据需要更改颜色或其他任何内容.
要了解它的详细信息,请看看
There is is event called Rowdatabound of gridview. That is fired for each row.Here you can access each cell of row and can change the color or anything as per your requirement.
To know details of it Have a look


这篇关于网格视图显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆