We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

DataGrid Validatin with ADO

Thread ID:

Created:

Updated:

Platform:

Replies:

98722 Mar 22,2011 01:02 PM Mar 23,2011 09:51 AM WPF 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 22, 2011 01:02 PM

Hello,

I'm having trouble implementing the IDataErrorInfo
while using an OledConnection.
How do I set up the property to return the column's value?

Here is my code:



public partial class MainWindow : Window
{
ObservableCollection collec = new ObservableCollection();
public MainWindow()
{
InitializeComponent();

string file = @"..\..\sample.xls";
OleDbConnection oConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + file +";Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1;\"");
oConn.Open();
OleDbCommand oCmd = new OleDbCommand("SELECT * FROM [Sheet1$]",oConn);
OleDbDataReader oReader = oCmd.ExecuteReader();

while (oReader.Read())
{
object[] rowValues = new object[oReader.FieldCount];
oReader.GetValues(rowValues);
collec.Add(new Order {OrderID= Int32.Parse(rowValues[0].ToString()),CustomerID=rowValues[1].ToString(),EmployeeID=rowValues[2].ToString(),ShipName=rowValues[3].ToString(),ShipAddress=rowValues[4].ToString(),ShipCity=rowValues[5].ToString(),Freight=rowValues[6].ToString() });
}

dataGrid.ItemsSource = collec;
}
}

public class Order : System.ComponentModel.IDataErrorInfo
{
public int OrderID { get; set; }
public string CustomerID { get; set; }
public string EmployeeID { get; set; }
public string ShipName { get; set; }
public string ShipAddress { get; set; }
public string ShipCity { get; set; }
public string Freight { get; set; }

public string Error
{
get { return string.Empty; }
}

public string this[string columnName]
{
get
{
var result = string.Empty;
if (columnName == "OrderID")
{
//this doesn't work:
if(this.OrderID.Value =...

}
return result;
}
}


}


thanks...



Rajasekar [Syncfusion]
Replied On March 23, 2011 09:51 AM

Hi Assaf,

Thanks for choosing Syncfusion products.

The query posted in this forum is similar to this incident #78560. Regarding this query we have posted solution in the incident #78560. Please follow this incident for further clarification.

For Your Reference, please find the sample in the below location,

Sample:< http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GDC_Excel_OleDbConnection369360711.zip >

Please let us know if you have any queries.

Thanks,
Rajasekar




CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;