Ready to get started?

Learn more about the CData ADO.NET Provider for AvaTax or download a free trial:

Download Now

DataBind AvaTax Data to the DevExpress Data Grid

Use the CData ADO.NET Provider for AvaTax with the DevExpress Windows Forms and Web controls to provide AvaTax data to a chart.

The CData ADO.NET Provider for AvaTax implements standard ADO.NET data access components that can be used with third-party controls. The standard ADO.NET process for databinding can be followed to enable bidirectional access to live data from UI controls. In this article we show how to use the CData components to databind to the DevExpress Windows Forms and Web controls; you will databind to a chart that displays current data.

The primary method for performing basic authentication is to provide your login credentials, as follows:

  • User: Set this to your username.
  • Password: Set this to your password.

Optionally, if you are making use of a sandbox environment, set the following:

  • UseSandbox: Set this to true if you are authenticating with a sandbox account.

Authenticating Using Account Number and License Key

Alternatively, you can authenticate using your account number and license key. Connect to data using the following:

  • AccountId: Set this to your Account Id. The Account Id is listed in the upper right hand corner of the admin console.
  • LicenseKey: Set this to your Avalara Avatax license key. You can generate a license key by logging into Avalara Avatax as an account adminstrator and navigating to Settings -> Reset License Key.

Windows Forms Controls

The code below shows how to populate a DevExpress chart with AvaTax data. The AvalaraAvataxDataAdapter binds to the Series property of the chart control. The Diagram property of the control defines the x- and y-axes as the column names.

using (AvalaraAvataxConnection connection = new AvalaraAvataxConnection( "User=MyUser;Password=MyPassword;")) { AvalaraAvataxDataAdapter dataAdapter = new AvalaraAvataxDataAdapter( "SELECT Id, TotalTax FROM Transactions WHERE Code = '051349'", connection); DataTable table = new DataTable(); dataAdapter.Fill(table); DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series(); chartControl1.Series.Add(series); series.DataSource = table; series.ValueDataMembers.AddRange(new string[] { "TotalTax" }); series.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Qualitative; series.ArgumentDataMember = "Id"; series.ValueScaleType = DevExpress.XtraCharts.ScaleType.Numerical; chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False; ((DevExpress.XtraCharts.SideBySideBarSeriesView)series.View).ColorEach = true; }

Web Controls

The code below shows how to populate a DevExpress Web control with AvaTax data. The AvalaraAvataxDataAdapter binds to the Series property of the chart; the Diagram property defines the x- and y-axes as the column names.

using DevExpress.XtraCharts; using (AvalaraAvataxConnection connection = new AvalaraAvataxConnection( "User=MyUser;Password=MyPassword;")) { AvalaraAvataxDataAdapter AvalaraAvataxDataAdapter1 = new AvalaraAvataxDataAdapter("SELECT Id, TotalTax FROM Transactions WHERE Code = '051349'", connection); DataTable table = new DataTable(); AvalaraAvataxDataAdapter1.Fill(table); DevExpress.XtraCharts.Series series = new Series("Series1", ViewType.Bar); WebChartControl1.Series.Add(series); series.DataSource = table; series.ValueDataMembers.AddRange(new string[] { "TotalTax" }); series.ArgumentScaleType = ScaleType.Qualitative; series.ArgumentDataMember = "Id"; series.ValueScaleType = ScaleType.Numerical; ((DevExpress.XtraCharts.SideBySideBarSeriesView)series.View).ColorEach = true; }