Converter to change a datagrid field whit id to description from database


hello.
(sorry english)

 i´m new in silverlight, in my app  fill datagrid whit data obtained table in database contains records of machines.
in database exists table kind of machines

n machines <--------------> 1 kind of machine

 

ie. 
kind of machine table:
1.:camera
2. notebook


kindofmachine : 1
property 1 : x;
property n : y

in field 'kindofmachine '  need grid shows me description, instead of id.

i made converter, can´t make work in  asyncronic mode


domain service converter class:
works, returns string

public partial class domainservice1    {    private string result;    public string gettipoequipo(int idtipoequipo)      {      var q = p in this.objectcontext.maestroequipos    p.idtipoequipo == idtipoequipo    select p;      foreach (var maestroequipos in q)    {    result = maestroequipos.tipoequipo;    }    return result.tostring();    }  
 

 

 

my xaml grid:

<sdk:datagrid autogeneratecolumns="false" height="212" horizontalalignment="left" itemssource="{binding elementname=equipodomaindatasource, path=data}" margin="65,0,0,0" x:name="equipodatagrid" rowdetailsvisibilitymode="visiblewhenselected" verticalalignment="top" width="auto" grid.row="1" >

 

<sdk:datagrid.columns>

<sdk:datagridtextcolumn x:name="idtipoequipocolumn" binding="{binding idtipoequipo,converter={staticresource converter}}" header="tipo equipo" width="sizetoheader" />

<sdk:datagridtextcolumn x:name="marcacolumn" binding="{binding path=marca}" header="marca" />

 

the converter:

 

public class idequipotostringconverter : ivalueconverter      {                              public object convert(object value, type targettype, object parameter, cultureinfo culture)          {                            domainservice1 ds = new domainservice1();              var result = ds.gettipoequipo((int)value);              result.completed += new eventhandler(result_completed);              return result;                     }                   public  object convertback(object value, type targettype, object parameter, cultureinfo culture)          {          return new notimplementedexception();          }                                 }      
datagrid filled correctly,  id description not converted, in place print : system.servicemodel.domainservices.client.invokeoperation`1[system.string]
 
 
thanks in advance;



Silverlight  >  Getting Started with Silverlight



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'