Accessing Column Names in Bound Data

6 posts, 0 answers
  1. Matthew
    Matthew avatar
    16 posts
    Member since:
    Jul 2011

    Posted 16 Aug 2011 Link to this post

    I am trying to write a test which can scale according to the data file being bound to it (using dynamic data binding). I need to use code to access the column names to prevent throwing exceptions. Does this.Data have properties where I can get the length of the array(DataTable) and the ColumnNames?

    If I try to use a DataTable object, I get this error

    The type 'System.Xml.Serialization.IXmlSerializable' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

    despite having the "using System.Xml;" statement appearing in the class header.

  2. Shashi
    Shashi avatar
    25 posts
    Member since:
    Feb 2011

    Posted 17 Aug 2011 Link to this post

    Matthew,

    That error indicates you may not have a reference to System.Xml in your project (you need this in addition to the using statement in the code).  Check if you see it under the References node of the project that contains the file.  If not, you can add it (command should be on the right mouse menu of the References node or on the main menu).

    Shashi
  3. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 18 Aug 2011 Link to this post

    Hi Shashi,

    Please read our article on How to Add an Assembly Reference  in the Standalone version. Than you can access all the loaded data using the ExecutionContext property of the test. For example, if you want to get the collection of columns use this code: 
    //Gets the collection of columns that belong to the table
    this.ExecutionContext.DataSource.Columns
          
    //Get the total number of the columns    
    this.ExecutionContext.DataSource.Columns.Count;
    Let me know if you need further help!

    All the best,
    Plamen
    the Telerik team
    Vote for Telerik Test Studio at the Annual Automation Honors Voting!
  4. Matthew
    Matthew avatar
    16 posts
    Member since:
    Jul 2011

    Posted 19 Aug 2011 Link to this post

    Thanks Shashi and Plamen,

    After adding the reference to the project and not just adding the 'using System.XML', the tests compile properly.
  5. Shashi
    Shashi avatar
    25 posts
    Member since:
    Feb 2011

    Posted 19 Aug 2011 Link to this post

    You are welcome, Matthew. 

    Just out of curiosity, were you using Visual Studio or the stand-alone version of WebUI? 

    My comments were for Visual Studio (apologies for not making that clear in my original post).

    Shashi
  6. Matthew
    Matthew avatar
    16 posts
    Member since:
    Jul 2011

    Posted 22 Aug 2011 Link to this post

    I was uisng the stand alone version of Test Studio actually.
Back to Top