Custom DataTable Attributes

Hi there,

I have a Business Entity which inherits from DataTable.

It has some custom properties like BaseLanguage.

My Business Process returns the filtered rows fine to the ObjectDataSource and binds to the new ASPDataList and using Eval and Bind displays my data.

The issue is this:

Why cant I bind to other properties of my BusinessEntity other than the Data Rows

I have tried putting them in ExtendedProperties and having them as simple Properties of my class. I dont get an error thrown when I bind to <%# Eval("BaseLAN") %> but I also dont get to see the value.

Any clues Is it simply the Bind or Eval syntax on ASP.NET that I am missing please

Thanks in advance,
Steve


Answer this question

Custom DataTable Attributes

  • appolospb


    Your best bet would be to ask this question on the ASP.NET Data Controls forum:
    http://forums.asp.net/140/ShowForum.aspx

    It looks like there have been a number of ObjectDataSource threads there.  I hope this information proves helpful.

    David Sceppa
    ADO.NET Program Manager
    Microsoft

  • Master81

    Thanks for your reply.

    Thats the weird thing. They are public and no error is thrown trying to bind to them

    A snippet of my class looks like this.

    public class ACCListHeader : DataTable

    {

    public ACCListHeader() {
       this.Columns.Add("PriceLabel", System.Type.GetType("System.String"));
       this.Columns.Add("ACC_AccommodationName", System.Type.GetType("System.String"));
    }

    private string _baseLAN;

    public string BaseLAN

    {

    get { return this._baseLAN; }

    set { this._baseLAN = value; }

    }

    }

    Then I populate my table by creating a new intance and adding rows. The rows render fine in the Bind("ACC_AccommodationName") or Eval("PriceLabel").

    But the Eval("BaseLAN") does display anything nor throw an error. I feel I am missing something simple. I am calling this Binding in my HeaderTemplate.

    I could cheat and add BaseLAN a column and populate it on each row but that just feels wrong.

    Any help appreciated.

    Cheers,
    Steve


  • dataking

    The only object binding I have done is using a simple class as the binding source, as in:



       public class Source
       
    {
          
    private string stringProp = "abc";
          
    public string StringProp
          {
             
    get { return stringProp; }
             
    set { stringProp = value; }
          }
       }

     


    Just a guess, but is it possible that the DataTable you've inherited from has taken control of the whole binding process


  • Bob Bogo

    I believe only public properties can be bound to.  Is it possible your properties have less visibility

    RLG

  • parkinson007

    Ok, found the issue.

    The ObjectDataSource only uses the first DataTable.

    And, special feature - even if you do put mutliple tables in your dataset that you return, ObjectDataSource will use the first table.

    Cheers,
    Steve

  • Custom DataTable Attributes