To display a value in Silverlight website based on its database table column value

76 views Asked by At

I have a database table which has a column named Status and the value in the "Status" column will be 1 or 0 or Null. What I am trying to achieve is if the value is 1 it should display On, If the value is 0 it should display Off, if the value is null, it should display null. Here is some of snippet which i have tried till now ,I am unable to figure it out how to display the result based on the table column value. I am attaching the sample output of database. Please provide some idea which may workout for me in this case
Output Display

#Accessing table value
public IQueryable<MSDS_VII> GetMSDS()
{
    return (
        from r in this._context.MSDS_VII
        orderby r.NO
        select r);
}

#Creating ria service
   public void GetMSDS(Action<CustomLoadOperation<MSDS_VII>> loadCompleted, object 
   userState = null, int pageSize = 20)
    {
        new CustomDataAdapter<MSDS_VII>(this.client, this.client.GetMSDSQuery(), this.client.MSDS_VIIs, pageSize, loadCompleted, userState);
    }

#View Model
public class MSDSStatusViewModel : BaseViewModel
{

    [ImportingConstructor]
    public MSDSStatusViewModel(IWindowManager windowManager, IEventAggregator eventAggregator, DomainServiceClient service)
        : base()
    {
        this.windowManager = windowManager;
        this.service = service;
        this.eventAggregator = eventAggregator;
        this.DisplayName = "MSDS VII Status";
    }

    public DomainCollectionView<MSDS_VII> msdsList;
   
    public DomainCollectionView<MSDS_VII> MSDSList
    {
        get
        {
            return this.msdsList;
        }
        set
        {
            this.msdsList = value;
            this.NotifyOfPropertyChange(() => MSDSList);
        }
    }


    public override void GetData()
    {
        this.service.GetMSDS(this.OnGeneralItemsLoadCompleted<MSDS_VII>);
    }

    public override void OnGeneralItemsLoadCompleted<TEntity>(CustomLoadOperation<TEntity> result)
    {
        base.OnGeneralItemsLoadCompleted(result);
        if (result.Result.IsComplete)
        {
            if (typeof(TEntity).Equals(typeof(MSDS_VII)))
            {
                MSDSList = result.CollectionView as DomainCollectionView<MSDS_VII>;                      
            }
        }
    }

#View xaml code
<c1:C1FlexGrid Grid.Row="1" ItemsSource="{Binding MSDSList}"  AutoGenerateColumns="False" HeadersVisibility="Column" GroupRowPosition="BelowData" MaxColumnWidth="500" c1:LicenseMode.Evaluation="True">
        <c1:C1FlexGrid.Columns>
           <c1:Column Binding="{Binding NO}" Header="NO."Width="70" />
           <c1:Column Binding="{Binding ITEM}" Header="Item" Width="400"  />
           <c1:Column Binding="{Binding STATUS}" Header="Status" Width="130" />
        </c1:C1FlexGrid.Columns>
 </c1:C1FlexGrid>
1

There are 1 answers

0
codeputer On

You need to create a custom converter to translate the value to one that's appropriate to the control, and vice versa. There are lots of examples on the web.. I found this one after a quick search that should help you.. IValueConvertor