Can some one please help me with this databinding problem
The problem that I have is in the binding, as when I try to simple bind a text box control to the data source in the data set I get an error message saying that I "cannot bind to a property or column on data source 'studentID'.
I cant understand this, as I copy the XML data source to a dataset that I have created and then I try do the above binding. I am able to create a datagrid and bind that to the data set for viewing the tables but I need to bind the text boxes in the windows forms to the columns such as StudentID in the dataset so I can display the current record on the windows form so that the relevant data can be shown in the correct boxes on the form and for updating.
//The code below creates a dataset and reads the xml source code and the schema into the new
//data set.
DataSet mydataset = new DataSet();
mydataset.ReadXml("C://Student1.xml");
mydataset.ReadXmlSchema("C://Student1.xml");
//The code below is where I actually try to bind a text box "StudID" to the source code
datamember'StudentID'. The table in the dataset is called 'students'. The program compiles ok but when I run the form, the error message as mentioned above is displayed and cannot bind.
txtStudID.DataBindings.Add("Text", mydataset.Students, "StudentID");
The xml source code is displayed below and 'StudentID' is the data member in the data to which am trying to bind to.
<?xml version="1.0" encoding="utf-8" ?>
<Register xmlns="http://tempuri.org/Students.xds">
<Students>
<Student StudentID="1" FirstName="Margaret" LastName="Glover" Address="125 Kentville Plains"
City="London" Course="002" Email="[email protected]" Phone="0024567" Comments=" "></Student>
<Student StudentID="2" FirstName="Abena" LastName="Otu" Address="45 Julesverne Avenue" City="Boston"
Course="001" Email="[email protected]" Phone="0023335" Comments=" "></Student>
<Student StudentID="3" FirstName="James" LastName="Bain" Address="2 Spring Close " City="Dundee"
Course="001" Email="[email protected]," Phone="0034456" Comments=" "></Student>
<Student StudentID="4" FirstName="Lucy" LastName="Lu" Address="45 Sparring Road" City="Birmingham"
Course="003" Email="[email protected]" Phone="06776227" Comments=" "></Student>
<Student StudentID="5" FirstName="Frank" LastName="Skinner" Address="34 Belchsview junction"
City="London" Course="004" Email="[email protected]" Phone="09988877" Comments=" "></Student>
<Student StudentID="ttgtgt"></Student>
</Students>
<Courses>
<Course CourseID="001" CourseName="Dev Web Apps with MS Visual C# .NET"></Course>
<Course CourseID="002" CourseName="Dev Web Apps With MS Visual Basic .NET"></Course>
<Course CourseID="003" CourseName="Dev Windows-Based Apps With MS VB .NET"></Course>
<Course CourseID="004" CourseName="Dev Windows-Based Apps With MS VC# .NET"></Course>
</Courses>
</
Register>
Any help in this matter would be greatly appreciated Thankyou