Re: Datagrid and switch
From: Karl (none)
Date: 08/19/04
- Next message: Jos: "Re: Datagrid and switch"
- Previous message: bruce barker: "Re: linked pages"
- In reply to: Arjen: "Datagrid and switch"
- Next in thread: Jos: "Re: Datagrid and switch"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 19 Aug 2004 13:29:31 -0400
The easiest way is to call on a function
<span class="Normal"><%#
ConvertFieldType((int)(DataBinder.Eval(Container.DataItem, "FieldType"))
%></span>
and then just define a function
public string ConvertFieldType(int fieldTypeId){
switch(fieldTypeId){
case 1:
return "cars";
....
}
}
The function can either be in your code behind or in a <Script
runat="server"> block
"Arjen" <boah123@hotmail.com> wrote in message
news:cg2m4k$4mu$1@news5.tilbu1.nb.home.nl...
> Hello,
>
> My datagrid shows some values out of a database.
> For example 1,1,2,3,2,3,4,1.
>
> Now these numbers are not realy nice... so I want to convert the numbers.
> If it is a 1 it must show cars.
> If it is a 2 is must show bikes.
>
> How can I convert this in C#?
>
> I have now this. (But doesn't works)
> Can somebody help me?
> Thanks!
>
> -----------
>
> <ItemTemplate>
> <span class="Normal">
> <%
> switch(DataBinder.Eval(Container.DataItem,"FieldType")) {
>
> case 0:
> break;
> case 1:
> break;
> case 2:
> break;
> case 3:
> break;
> case 4:
> break;
> case 5:
> break;
> }
> %>
> </span>
> </ItemTemplate>
>
>
- Next message: Jos: "Re: Datagrid and switch"
- Previous message: bruce barker: "Re: linked pages"
- In reply to: Arjen: "Datagrid and switch"
- Next in thread: Jos: "Re: Datagrid and switch"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|