This is a migrated thread and some comments may be shown as answers.

Accessing Column Names in Bound Data

5 Answers 147 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 17 Aug 2011, 12:12 AM
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.

5 Answers, 1 is accepted

Sort by
0
Shashi
Top achievements
Rank 1
answered on 17 Aug 2011, 02:25 PM
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
0
Plamen
Telerik team
answered on 18 Aug 2011, 12:05 PM
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!
0
Matthew
Top achievements
Rank 1
answered on 19 Aug 2011, 09:00 PM
Thanks Shashi and Plamen,

After adding the reference to the project and not just adding the 'using System.XML', the tests compile properly.
0
Shashi
Top achievements
Rank 1
answered on 19 Aug 2011, 09:39 PM
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
0
Matthew
Top achievements
Rank 1
answered on 22 Aug 2011, 05:02 PM
I was uisng the stand alone version of Test Studio actually.
Tags
General Discussions
Asked by
Matthew
Top achievements
Rank 1
Answers by
Shashi
Top achievements
Rank 1
Plamen
Telerik team
Matthew
Top achievements
Rank 1
Share this question
or