Hi,
As Nicholas suggested it's better if you can do it in the SP, now in the
case that the meaning of the values are not saved in the DB or just that you
want to display it someway different ; like a different color depending of
the priority ; you can use a code like this:
in the aspx page:
<asp:templateco lumn ItemStyle-VerticalAlign=" Top"
ItemStyle-Width="70" ItemStyle-HorizontalAlign ="left"
ItemStyle-Cssclass="sideb ar2">
<itemtemplate >
<asp:Label CssClass='<%# SelectDaysLeftC ssClass(
((Accident)Cont ainer.DataItem) ) %>' Runat="server" Text='<%#
((Accident)Cont ainer.DataItem) .Status %>' ID="Label2">
</asp:Label>
</itemtemplate>
</asp:templatecol umn>
As you can see I use a method to return the correct CssClass of the label
depending of the element being binded.
BTW, I bind the grid to a strong typed collection, but its the same if a
datagrid/datatable is used.
later in the code behind :
protected string SelectDaysLeftC ssClass( Accident accident)
{
//If closed get the "blue" one
if ( accident.Status == Accident.Accide ntStatus.Closed )
return "textblueRe al";
//The record is open, if overdue red, normal otherwise
if ( accident.DaysLe ft > -1 )
return "text";
else
return "textred";
}
The same thing you can use to display an interpretation of a value from the
database.
Hope this help,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"spmm_pls" <sp******@yahoo .com> wrote in message
news:f5******** *************** ***@posting.goo gle.com...
Hi,
Could some1 please tell me what the best way is to adjust the value of
a column in my databound datagrid (in ASP.NET)
For example my database returns the values 1,2 and 3 in the column
Priority. But 1,2 and 3 actually represent "Low", "Medium" and "High".
So instead of a column filled with 1,2,3's I want a column filled with
Low,Medium,High 's. How do I do that??
Can (should) this be done in my C# code, or do I have to adjust my
stored procedure on which the datagrid is based?
thanks!