Export (0) Print
Expand All

ErrorProvider.DataMember Property

Gets or sets the list within a data source to monitor.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public string DataMember { get; set; }
/** @property */
public String get_DataMember ()

/** @property */
public void set_DataMember (String value)

public function get DataMember () : String

public function set DataMember (value : String)

Property Value

The string that represents a list within the data source specified by the DataSource to be monitored. Typically, this will be a DataTable.

The DataMember is a navigation string based on DataSource.

To avoid conflicts at run time that can occur when changing DataSource and DataMember, you should use BindToDataAndErrors instead of setting DataSource and DataMember individually.

The following code example shows how to use the ErrorProvider with a DataSource and DataMember to indicate a data error to the user.

private void InitializeComponent()
 {
     // Standard control setup.
     //....
     // You set the DataSource to a data set, and the DataMember to a table.
     errorProvider1.DataSource = dataSet1 ;
     errorProvider1.DataMember = dataTable1.TableName ;
     errorProvider1.ContainerControl = this ;
     errorProvider1.BlinkRate = 200 ;
     //...
     // Since the ErrorProvider control does not have a visible component,
     // it does not need to be added to the form. 
 }
 
 private void buttonSave_Click(object sender, System.EventArgs e)
 {
     // Checks for a bad post code.
     DataTable CustomersTable;
     CustomersTable = customersDataSet1.Tables["Customers"];
     foreach (DataRow row in (CustomersTable.Rows)) 
	 {
         if (Convert.ToBoolean(row["PostalCodeIsNull"])) 
         {
             row.RowError="The Customer details contain errors";
             row.SetColumnError("PostalCode", "Postal Code required");
         } 
     } 
 }


private void InitializeComponent()
{
    // Standard control setup.
    //....
    // You set the DataSource to a data set, and the DataMember 
    // to a table.
    errorProvider1.set_DataSource(dataSet1);
    errorProvider1.set_DataMember(dataTable1.get_TableName());
    errorProvider1.set_ContainerControl(this);
    errorProvider1.set_BlinkRate(200);
    //...
    // Since the ErrorProvider control does not have a visible component,
    // it does not need to be added to the form. 
} //InitializeComponent

protected void buttonSave_Click(Object sender, System.EventArgs e)
{
    // Checks for a bad post code.
    DataTable customersTable;
    customersTable = customersDataSet1.get_Tables().get_Item("Customers");
    for (int iCtr = 0; iCtr < customersTable.get_Rows().get_Count(); 
         iCtr++) {
        DataRow row = customersTable.get_Rows().get_Item(iCtr);
        if (Convert.ToBoolean(row.get_Item("PostalCodeIsNull"))) {
            row.set_RowError("The Customer details contain errors");
            row.SetColumnError("PostalCode", "Postal Code required");
        }
    }
} //buttonSave_Click

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft