mardi 4 août 2015

changing label text and label background color in ASP.MVC WebGrid

I am rewriting an ASP.NET webform app to ASP.NET MVC. In the webform, there is a gridview with the the following gridview column code:

<asp:TemplateField HeaderText="PREV STAT MISSION"  ItemStyle-HorizontalAlign="Center" >

' BackColor= '<%# Item.PREV_STAT_MISSION == 1 ? System.Drawing.Color.Green : Item.PREV_STAT_MISSION == 2 ? System.Drawing.Color.Yellow : Item.PREV_STAT_MISSION == 3 ? System.Drawing.Color.Red : Item.PREV_STAT_MISSION == 4 ? System.Drawing.Color.Black : Item.PREV_STAT_MISSION == 5 ? System.Drawing.Color.Blue : System.Drawing.Color.Transparent %>' Font-Bold="true" Text='<%# Item.PREV_STAT_MISSION == 1 ? " F1 " : Item.PREV_STAT_MISSION == 2 ? " F2 " : Item.PREV_STAT_MISSION == 3 ? " F3 " : Item.PREV_STAT_MISSION == 4 ? " F4 " : Item.PREV_STAT_MISSION == 5 ? " F5 " : "" %>' />

I am using ASP.NET MVC WebGrid. So far, I rewritten the code like this

grid.Column("PREV_STAT_MISSION", format: @ @item.PREV_STAT_MISSION == 1 ? " F1 " : @item.PREV_STAT_MISSION == 2 ? " F2 " : @item.PREV_STAT_MISSION == 3 ? " F3 " : @item.PREV_STAT_MISSION == 4 ? " F4 " : @item.PREV_STAT_MISSION == 5 ? " F5 " : "" ),

But it does not work. I am not sure how to change the label text and color using Grid.Column. Any help is greatly appreciated. Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire