UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Windows Presentation Foundation Question - Linq    
 
   
ConorS
post May 12 2014, 08:29 AM
Post#1



Posts: 1,357
Joined: 1-April 04
From: Northern Ireland (Newry)


Hi
Here is my question
On load of a new WPF window i have the following code:
C# Code
...
using (BlueApp.MyLinqToDataDataContext db = new MyLinqToDataDataContext())
{
var allTitles = from t in db.PN_Projects
select new { t.PN_ProjectID, t.PN_ProjectTitle };
CGrid.ItemsSource = allTitles;
}
...
XAML:
<DataGrid AutoGenerateColumns="false" Name="CGrid">
<DataGrid.Columns>
<DataGridTextColumn Header="ProjectID" Binding="{Binding Path=PN_ProjectID}" Width="200"/>
<DataGridTextColumn Header="ProjectTitle" Binding="{Binding Path=PN_ProjectTitle}" Width="200"/>
</DataGrid.Columns>
</DataGrid>
Using Linq, this piece of code pushes a data into a datagrid called "CGrid".
When I run the application, the data displays fine.
Next move, the user clicks, sorrys selects a record, i want to get at the variable "PN_ProjectId" at its value.
When i use the code :
private void CGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
{
MessageBox.Show(CGrid.SelectedItem.ToString());
}
It spits up on screen the following:
"{ PN_ProjectID = 1, PN_ProjectTitle = My Title1"
How do i get at the individual variables? Reference them I mean.
I want to get just the "PN_ProjectID". How do i reference it?
I'm new to this.
Thanks in advance!
Regards
Conor
Go to the top of the page
 
ConorS
post May 14 2014, 05:55 AM
Post#2



Posts: 1,357
Joined: 1-April 04
From: Northern Ireland (Newry)


its ok, i was able to get an answer for this.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    16th December 2017 - 05:53 AM