Export (0) Print
Expand All

BaseDataList.IsBindableType Method

Determines whether the specified data type can be bound to a list control that derives from the BaseDataList class.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public static bool IsBindableType(
	Type type


Type: System.Type

A System.Type that contains the data type to test.

Return Value

Type: System.Boolean
true if the specified data type can be bound to a list control that derives from the BaseDataList class; otherwise, false.

Use the IsBindableType static method to determine whether the specified data type can be bound to a list control that inherits from the BaseDataList class. The supported data types are System.Boolean, System.Byte, System.SByte, System.Int16, System.UInt16, System.Int32, System.UInt32, System.Int64, System.UInt64, System.Char, System.Double, System.Single, System.DateTime, System.Decimal, and System.String.

The following code example demonstrates how to use the IsBindableType property to determine whether values of a certain data type can be bound to a DataGrid control.

<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" >
   <script runat="server">

      DataView CreateDataSource() 

         // Create sample data for the DataGrid control.
         DataTable dt = new DataTable();
         DataRow dr;

         // Define the columns of the table.
         dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
         dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
         dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));

         // Populate the table with sample values.
         for (int i = 0; i < 9; i++) 
            dr = dt.NewRow();

            dr[0] = i;
            dr[1] = "Item " + i.ToString();
            dr[2] = 1.23 * (i + 1);


         DataView dv = new DataView(dt);
         return dv;

      void Page_Load(Object sender, EventArgs e) 

         // Load sample data only once when the page is first loaded.
         if (!IsPostBack) 

            // Retrieve sample data.
            DataView Source = CreateDataSource();

            // Bind the data source to the DataGrid control if each column  
            // in the data source contains a data type that is compatible  
            // with the DataGrid; otherwise, display an error message. 

               ItemsGrid.DataSource = Source;


               Message.Text = "The data source is not compatible with the DataGrid control.";




      bool ValidateSourceTypes(DataView Source)

         // Test the data type of each column in the data source to make 
         // sure it is compatible with the DataGrid control.

         // Initialize the success flag to true.
         bool Success = true;

         // Iterate through each column of the data source and test the 
         // data type for compatibility with the DataGrid control. 
         foreach(DataColumn column in Source.Table.Columns)
               Success = false;

         return Success;



<head runat="server">
    <title>BaseDataList IsBindableType Example</title>

   <form id="form1" runat="server">

      <h3>BaseDataList IsBindableType Example</h3>

      <asp:DataGrid id="ItemsGrid"

         <HeaderStyle BackColor="#00aaaa">


      <br /><br />

      <asp:Label id="Message" 



.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft