The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Stuck with DataBinding

Last post 04-26-2008, 7:22 AM by dewacorp.alliances. 4 replies.
Sort Posts: Previous Next
  •  04-26-2008, 4:52 AM 9035

    Stuck with DataBinding

    Hi there

    I have this code that try to combine two fields into one (not sure whether this is the best approach)

    Code:
    protected GlbSupplierRateRegionsViewCollection GetTariffNetworkDistributorRateRegions(int SupplierID)
            {
                try
                {
                    GlbSupplierRateRegionsViewCollection collection = new GlbSupplierRateRegionsViewCollection();
                    collection.Query
                           .Select(collection.Query.SupplierRateRegionID,
                                   collection.Query.SupplierRateName + " - " + collection.Query.ConfigurationRegionName
                           )
                           .Where
                           (
                               collection.Query.SupplierRateRegionIsActive.Equal(true),
                               collection.Query.ConfigurationIsActive.Equal(true),
                               collection.Query.SupplierID.Equal(SupplierID)
                           )
                           .OrderBy(collection.Query.ConfigurationRegionName.Ascending);
                    collection.Query.Load();
                    return collection;
                }
                catch
                {
                    return null;
                }
            }.
     Now I have a telerik combox box and would like data binding this combined field.Generally I use something like this 

    GlbSupplierRateRegionsViewMetadata.PropertyNames.??? but since ths is a combined field I am not sure what is the best approach on this.

    I can probably create a view to combine these 2 value but I thought there must be away within this API can handle this situation.

     

    Code:
    protected void LoadTariffNetworkDistributorRateRegions(string supplierID)
            {
                GlbSupplierRateRegionsViewCollection tariffNetworkDistributorRateRegions = GetTariffNetworkDistributorRateRegions(Convert.ToInt32(supplierID));
                radcmbbxTariffNetworkDistributorRateRegion.DataSource = tariffNetworkDistributorRateRegions;
                radcmbbxTariffNetworkDistributorRateRegion.DataTextField = GlbSupplierRateRegionsViewMetadata.PropertyNames.ConfigurationRegionName;
                radcmbbxTariffNetworkDistributorRateRegion.DataValueField = GlbSupplierRateRegionsViewMetadata.PropertyNames.SupplierRateRegionID;
                radcmbbxTariffNetworkDistributorRateRegion.DataBind();
                foreach (RadComboBoxItem item in radcmbbxTariffNetworkDistributorRateRegion.Items)
                {
                    item.ToolTip = item.Text;
                }
            }

     

    Thanks

     

     

     

     

     

     

     

  •  04-26-2008, 5:36 AM 9037 in reply to 9035

    Re: Stuck with DataBinding

    Try this:

     

    Code:
    .Select
    (
        collection.Query.SupplierRateRegionID,
        (collection.Query.SupplierRateName + " - " + collection.Query.ConfigurationRegionName).As("SpecialBinder")
    )
     Notice I give the expression the alias "SpecialBinder" which is a special property on all entities just for this exact purpose.

    Then you can bind your DataTextField to "SpecialBinder" 

     


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  04-26-2008, 6:54 AM 9039 in reply to 9037

    Re: Stuck with DataBinding

    Thanks for this and how to bind this?

    So it will be like this: GlbSupplierRateRegionsViewMetadata.PropertyNames.SpecialBinder ?!?!

    I don't this it's on Metadata though?

    Thanks

  •  04-26-2008, 7:13 AM 9040 in reply to 9039

    Re: Stuck with DataBinding

    radcmbbxTariffNetworkDistributorRateRegion.DataTextField = "SpecialBinder";

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  04-26-2008, 7:22 AM 9041 in reply to 9040

    Re: Stuck with DataBinding

    Gee I don't know if you can do that. Thanks :)

     

     

View as RSS news feed in XML