C#: LINQ to SQL Tutorial on youtube.com - Bindings Issue
I don't know if anyone has watched the "Visual Studio 2008, Linq to SQL, C#, and WPF" 21 part tutorial on youtube.com, but I was going through the tutorial and got to the part that I added a datagrid to my WPF. I have SQL Express where I had manually created a database with tables. In the program we created a database connection to the database as well as a dataset to its tables.
However, I noticed that when the person giving that tutorial added a datagrid to their WPF, it automatically placed a "my" in front of the element "Datagrid"开发者_C百科.
Example: <my:DataGrid AutoGenerateColumns="False" ............/>
However, mine is:
<DataGrid AutoGenerateColumns="False" ............../>
I don't know how much this affects the progrm if any, but the problem that I encountered was when I am trying to add Bindings to some Elements,
<DataGridTextColumn Header="Student ID" Binding="(Binding Path=StudentID)" />
It doesn't appear to be working correctly for the simple fact that the text coloring is not displaying as I would expect and if I misspell "Path" or "StudentID" it doesn't compute an error or change in anyway. StudentID is the Primary Key of the "Student" table I have created in a DB called "SchoolSystem".
I am new to C# and LINQ to SQL so any advice would be appreciated.
I did try to reach out to the creator of the video's but unsuccessfully so far.
Try
<DataGridTextColumn Header="Student ID" Binding="{Binding Path=StudentID}" />
or
<DataGridTextColumn Header="Student ID" Binding="{Binding StudentID}" />
Depending on how the ItemsSource was bound to the DataGrid. Also notice you were using parenthesis () instead of curly braces {} in the Binding.
The reason for this was that I was using a () instead of {}.
Thanks though.
精彩评论