C# 到Sql Server的XAML绑定
我有一个SQL Server DB,其中包含以下表和关系: 包含许多会话的作业。 包含许多休息的会话 首先,不要被发布在这里的大量代码所吓倒。相关部分是列表中突出显示的部分,其余部分只是为了比较,看看我错在哪里 在XAML中,当绑定作业时,我正在尝试并成功。我让它过滤出正确的会话。没问题 我的问题是,当我试图让它过滤属于每个会话的中断时,它不会工作,但我使用的是所有相同的原则 我不使用(也不感兴趣)Linq2Sql,因为它创建了太多额外的类,使我的代码膨胀。我只是使用直接数据绑定 我以前问过这个问题并发布了代码,但我从未得到任何回复,因为代码太长,无法在合理的时间范围内阅读 我的问题是,我做错了什么。我的印象是,既然我能够成功地绑定和过滤会话,那么我就应该能够同样地处理会话和过滤中断。但它不起作用 我有点绝望的帮助,并通知任何答案 编辑:我再次包含代码示例。我不是为了保密和版权而隐藏代码。这只是我学习的一个练习,所以我不介意发布完整的代码。但是它很长。因此,我将只发布我认为相关的部分。如果你想要更多,尽管问 对于那些有兴趣跳到问题所在的好部分的人,请查看“中断”列表框的部分。其余的只是用于比较,以帮助您进行调试。下面还有C#代码可以进一步帮助您。再次查看列表部分,其余部分仅用于调试 下面是相关的XAMLC# 到Sql Server的XAML绑定,c#,sql-server,sql-server-2008,xaml,data-binding,C#,Sql Server,Sql Server 2008,Xaml,Data Binding,我有一个SQL Server DB,其中包含以下表和关系: 包含许多会话的作业。 包含许多休息的会话 首先,不要被发布在这里的大量代码所吓倒。相关部分是列表中突出显示的部分,其余部分只是为了比较,看看我错在哪里 在XAML中,当绑定作业时,我正在尝试并成功。我让它过滤出正确的会话。没问题 我的问题是,当我试图让它过滤属于每个会话的中断时,它不会工作,但我使用的是所有相同的原则 我不使用(也不感兴趣)Linq2Sql,因为它创建了太多额外的类,使我的代码膨胀。我只是使用直接数据绑定 我以前问过这个
<!--Jobs List box - Works fine-->
<ListBox Name="lstJobs" DockPanel.Dock="Top"
MinWidth="150" MinHeight="200" MaxHeight="250"
ScrollViewer.VerticalScrollBarVisibility="Visible"
SelectionChanged="lstJobs_SelectionChanged"
IsSynchronizedWithCurrentItem="True"
DataContext="{Binding Tables[JobDetails]}"
ItemsSource="{Binding}"
>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<StackPanel Orientation="Horizontal" Margin="3,0,3,0">
<TextBlock Text="{Binding Path=Title}"/>
<TextBlock Text=" "/>
<TextBlock Text="{Binding Path=ID}"/>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!--How Jobs listbox is bound to relevant fields in jobs table. This works fine-->
<TextBox Text="{Binding ElementName=lstJobs, Path=SelectedItem.ID, UpdateSourceTrigger=PropertyChanged}" Name="txtJobNo" Grid.Row="1" IsEnabled="False"/>
<TextBox Text="{Binding ElementName=lstJobs, Path=SelectedItem.Title, UpdateSourceTrigger=PropertyChanged}" Name="txtJobTitle" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"/>
<TextBox Text="{Binding ElementName=lstJobs, Path=SelectedItem.Description, UpdateSourceTrigger=PropertyChanged}" Name="txtJobDesc" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Grid.RowSpan="2"/>
<!--Sessions List box, Automatically filtered based on relationship (see last binding line). This works fine too-->
<ListBox Name="lstSessions" DockPanel.Dock="Top" MinWidth="150"
MinHeight="200" MaxHeight="220"
ScrollViewer.VerticalScrollBarVisibility="Visible"
SelectionChanged="lstSessions_SelectionChanged"
IsSynchronizedWithCurrentItem="True"
DataContext="{Binding Path=Tables[JobDetails]}"
ItemsSource="{Binding Path=relJobDetailsSessionDetails}"
>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<StackPanel Orientation="Horizontal" Margin="3,0,3,0">
<TextBlock Text="{Binding Path=Title}" />
<TextBlock Text="{Binding Path=ID}" />
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!--How Sessions listbox is bound to relevant fields in Sessions table. This works fine-->
<TextBox Name="txtSessionNo" Text="{Binding ElementName=lstSessions, Path=SelectedItem.ID, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="0"/>
<TextBox Name="txtSessionTitle" Text="{Binding ElementName=lstSessions, Path=SelectedItem.Title, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3"/>
<TextBox Name="txtSessionDesc" Text="{Binding ElementName=lstSessions, Path=SelectedItem.Description, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Grid.RowSpan="2"/>
<!--Breaks List box, Should be automatically filtered (it is), but it does not change when a job or session is selected. Why?? -->
<ListBox Name="lstBreaks" MinWidth="150" MinHeight="140" MaxHeight="140"
ScrollViewer.VerticalScrollBarVisibility="Visible"
SelectionChanged="lstBreaks_SelectionChanged"
IsSynchronizedWithCurrentItem="True"
DataContext="{Binding Path=Tables[SessionDetails]}"
ItemsSource="{Binding Path=relSessionDetailsBreakDetails}"
>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<StackPanel Orientation="Horizontal" Margin="3,0,3,0">
<TextBlock Text="{Binding Path=Title}" />
<TextBlock Text="{Binding Path=ID}" />
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!--How Breaks listbox is bound to relevant fields in Breaks table. This works fine as before-->
<TextBox Name="txtBreakNo" Text="{Binding ElementName=lstBreaks, Path=SelectedItem.ID, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="0"/>
<TextBox Name="txtBreakTitle" Text="{Binding ElementName=lstBreaks, Path=SelectedItem.Title, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"/>
<ComboBox Name="cbxBreakType" Text="{Binding ElementName=lstBreaks, Path=SelectedItem.Description, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="3"/>
根据要求,这里有一个完整的复制案例 更新:使用链接中的工作代码进行更新。看起来答案绑定到SelectedItem=>关系。事实上,这很合乎逻辑 XAML:
代码隐藏:
using System;
using System.Data;
using System.Windows;
using System.Windows.Controls;
namespace WpfApplication2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
CreateData();
this.DataContext = Data;
}
public DataSet Data { get; set; }
private void CreateData()
{
Data = new DataSet();
Data.Tables.Add(CreateJobTable());
Data.Tables.Add(CreateSessionsTable());
Data.Tables.Add(CreateBreaks());
DataRelation relation = GetJobSessionRelations();
DataRelation relation2 = GetSessionBreakRelations();
Data.Relations.AddRange(new[] {relation, relation2});
}
private DataTable CreateJobTable()
{
var jobs = new DataTable();
jobs.TableName = "JobDetails";
var col1 = new DataColumn("ID");
var col2 = new DataColumn("Title");
var col3 = new DataColumn("Description");
col1.DataType = Type.GetType("System.Int32");
col2.DataType = Type.GetType("System.String");
col3.DataType = Type.GetType("System.String");
jobs.Columns.Add(col1);
jobs.Columns.Add(col2);
jobs.Columns.Add(col3);
DataRow row = jobs.NewRow();
row["ID"] = 1;
row["Title"] = "Job 1";
row["Description"] = "Job Desc 1";
jobs.Rows.Add(row);
DataRow row2 = jobs.NewRow();
row2["ID"] = 2;
row2["Title"] = "Job 2";
row2["Description"] = "Job Desc 2";
jobs.Rows.Add(row2);
return jobs;
}
private DataTable CreateSessionsTable()
{
var sessions = new DataTable();
sessions.TableName = "SessionDetails";
var col1 = new DataColumn("ID");
var col2 = new DataColumn("Title");
var col3 = new DataColumn("Description");
var col4 = new DataColumn("JobID");
col1.DataType = Type.GetType("System.Int32");
col2.DataType = Type.GetType("System.String");
col3.DataType = Type.GetType("System.String");
col4.DataType = Type.GetType("System.Int32");
sessions.Columns.Add(col1);
sessions.Columns.Add(col2);
sessions.Columns.Add(col3);
sessions.Columns.Add(col4);
DataRow row = sessions.NewRow();
row["ID"] = 1;
row["Title"] = "Session 1";
row["Description"] = "Session Desc 1";
row["JobID"] = 1;
sessions.Rows.Add(row);
DataRow row2 = sessions.NewRow();
row2["ID"] = 2;
row2["Title"] = "Session 2";
row2["Description"] = "Session Desc 2";
row2["JobID"] = 1;
sessions.Rows.Add(row2);
DataRow row3 = sessions.NewRow();
row3["ID"] = 3;
row3["Title"] = "Session 3";
row3["Description"] = "Session Desc 3";
row3["JobID"] = 2;
sessions.Rows.Add(row3);
DataRow row4 = sessions.NewRow();
row4["ID"] = 4;
row4["Title"] = "Session 4";
row4["Description"] = "Session Desc 4";
row4["JobID"] = 2;
sessions.Rows.Add(row4);
return sessions;
}
private DataTable CreateBreaks()
{
var breaks = new DataTable();
breaks.TableName = "BreakDetails";
var col1 = new DataColumn("ID");
var col2 = new DataColumn("Title");
var col3 = new DataColumn("Description");
var col4 = new DataColumn("SessionID");
col1.DataType = Type.GetType("System.Int32");
col2.DataType = Type.GetType("System.String");
col3.DataType = Type.GetType("System.String");
col4.DataType = Type.GetType("System.Int32");
breaks.Columns.Add(col1);
breaks.Columns.Add(col2);
breaks.Columns.Add(col3);
breaks.Columns.Add(col4);
DataRow row = breaks.NewRow();
row["ID"] = 1;
row["Title"] = "Break 1";
row["Description"] = "Break Desc 1";
row["SessionID"] = 1;
breaks.Rows.Add(row);
DataRow row2 = breaks.NewRow();
row2["ID"] = 2;
row2["Title"] = "Break 2";
row2["Description"] = "Break Desc 2";
row2["SessionID"] = 2;
breaks.Rows.Add(row2);
DataRow row3 = breaks.NewRow();
row3["ID"] = 3;
row3["Title"] = "Break 3";
row3["Description"] = "Break Desc 3";
row3["SessionID"] = 3;
breaks.Rows.Add(row3);
DataRow row4 = breaks.NewRow();
row4["ID"] = 4;
row4["Title"] = "Break 4";
row4["Description"] = "Break Desc 4";
row4["SessionID"] = 4;
breaks.Rows.Add(row4);
return breaks;
}
private DataRelation GetSessionBreakRelations()
{
return new DataRelation("relJobDetailsSessionDetails", Data.Tables["JobDetails"].Columns["ID"],
Data.Tables["SessionDetails"].Columns["JobID"]);
}
private DataRelation GetJobSessionRelations()
{
var dataRelation = new DataRelation("relSessionDetailsBreakDetails", Data.Tables["SessionDetails"].Columns["ID"],
Data.Tables["BreakDetails"].Columns["SessionID"]);
return dataRelation;
}
private void lstJobs_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
private void lstSessions_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
private void lstBreaks_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
}
}
使用系统;
使用系统数据;
使用System.Windows;
使用System.Windows.Controls;
命名空间WpfApplication2
{
///
///MainWindow.xaml的交互逻辑
///
公共部分类主窗口:窗口
{
公共主窗口()
{
初始化组件();
CreateData();
this.DataContext=数据;
}
公共数据集数据{get;set;}
私有void CreateData()
{
数据=新数据集();
Add(CreateJobTable());
Add(CreateSessionsTable());
Data.Tables.Add(CreateBreaks());
DataRelation=GetJobSessionRelations();
DataRelation2=GetSessionBreakRelations();
Data.Relations.AddRange(新的[]{Relations,relation2});
}
私有数据表CreateJobTable()
{
var jobs=新数据表();
jobs.TableName=“JobDetails”;
var col1=新数据列(“ID”);
var col2=新数据列(“标题”);
var col3=新数据列(“说明”);
col1.DataType=Type.GetType(“System.Int32”);
col2.DataType=Type.GetType(“System.String”);
col3.DataType=Type.GetType(“System.String”);
jobs.Columns.Add(col1);
jobs.Columns.Add(col2);
jobs.Columns.Add(col3);
DataRow row=jobs.NewRow();
行[“ID”]=1;
行[“标题”]=“作业1”;
行[“说明”]=“作业说明1”;
jobs.Rows.Add(行);
DataRow row2=jobs.NewRow();
第2行[“ID”]=2;
第2行[“标题”]=“作业2”;
第2行[“说明”]=“作业说明2”;
jobs.Rows.Add(第2行);
返回工作岗位;
}
私有数据表CreateSessionTable()
{
var sessions=newdatatable();
sessions.TableName=“SessionDetails”;
var col1=新数据列(“ID”);
var col2=新数据列(“标题”);
var col3=新数据列(“说明”);
var col4=新数据列(“JobID”);
col1.DataType=Type.GetType(“System.Int32”);
col2.DataType=Type.GetType(“System.String”);
col3.DataType=Type.GetType(“System.String”);
col4.DataType=Type.GetType(“System.Int32”);
sessions.Columns.Add(col1);
sessions.Columns.Add(col2);
sessions.Columns.Add(col3);
sessions.Columns.Add(col4);
DataRow行=sessions.NewRow();
行[“ID”]=1;
行[“标题”]=“会话1”;
行[“说明”]=“会话说明1”;
行[“作业ID”]=1;
sessions.Rows.Add(row);
DataRow row2=sessions.NewRow();
第2行[“ID”]=2;
第2行[“标题”]=“会话2”;
第2行[“说明”]=“会话说明2”;
第2行[“作业ID”]=1;
sessions.Rows.Add(第2行);
DataRow row3=sessions.NewRow();
第3行[“ID”]
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".5*"/>
<ColumnDefinition Width=".5*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height=".33*"/>
<RowDefinition Height=".33*"/>
<RowDefinition Height=".33*"/>
</Grid.RowDefinitions>
<!--Jobs List box - Works fine-->
<ListBox Name="lstJobs" Grid.Column="0" Grid.Row="0"
MinWidth="150"
MinHeight="200"
MaxHeight="250"
ScrollViewer.VerticalScrollBarVisibility="Visible"
SelectionChanged="lstJobs_SelectionChanged"
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Path=JobDetails}"
>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<StackPanel Orientation="Horizontal" Margin="3,0,3,0">
<TextBlock Text="{Binding Path=ID}"/>
<TextBlock Text="{Binding Path=Title}"/>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!--How Jobs listbox is bound to relevant fields in jobs table. This works fine-->
<StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="0">
<TextBox Text="{Binding ElementName=lstJobs, Path=SelectedItem.ID, UpdateSourceTrigger=PropertyChanged}"
Name="txtJobNo" Grid.Row="1" IsEnabled="False"/>
<TextBox Text="{Binding ElementName=lstJobs, Path=SelectedItem.Title, UpdateSourceTrigger=PropertyChanged}"
Name="txtJobTitle" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"/>
<TextBox Text="{Binding ElementName=lstJobs, Path=SelectedItem.Description, UpdateSourceTrigger=PropertyChanged}"
Name="txtJobDesc" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Grid.RowSpan="2"/>
</StackPanel>
<!--Sessions List box, Automatically filtered based on relationship (see last binding line). This works fine too -->
<ListBox Name="lstSessions" Grid.Column="0" Grid.Row="1"
DockPanel.Dock="Top"
MinWidth="150"
MinHeight="200"
MaxHeight="220"
ScrollViewer.VerticalScrollBarVisibility="Visible"
SelectionChanged="lstSessions_SelectionChanged"
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding ElementName=lstJobs, Path=SelectedItem.relJobDetailsSessionDetails}"
>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<StackPanel Orientation="Horizontal" Margin="3,0,3,0">
<TextBlock Text="{Binding Path=Title}" />
<TextBlock Text="{Binding Path=ID}" />
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!--How Sessions listbox is bound to relevant fields in Sessions table. This works fine-->
<StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="1">
<TextBox Name="txtSessionNo" Text="{Binding ElementName=lstSessions, Path=SelectedItem.ID, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="1" Grid.Column="0"/>
<TextBox Name="txtSessionTitle" Text="{Binding ElementName=lstSessions, Path=SelectedItem.Title, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3"/>
<TextBox Name="txtSessionDesc" Text="{Binding ElementName=lstSessions, Path=SelectedItem.Description, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Grid.RowSpan="2"/>
</StackPanel>
<!--Breaks List box, Should be automatically filtered (it is), but it does not change when a job or session is selected. Why?? -->
<ListBox Name="lstBreaks" Grid.Column="0" Grid.Row="2"
MinWidth="150"
MinHeight="140"
MaxHeight="140"
ScrollViewer.VerticalScrollBarVisibility="Visible"
SelectionChanged="lstBreaks_SelectionChanged"
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding ElementName=lstSessions, Path=SelectedItem.relSessionDetailsBreakDetails}"
>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<StackPanel Orientation="Horizontal" Margin="3,0,3,0">
<TextBlock Text="{Binding Path=Title}" />
<TextBlock Text="{Binding Path=ID}" />
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!--How Breaks listbox is bound to relevant fields in Breaks table. This works fine as before-->
<StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="2">
<TextBox Name="txtBreakNo" DockPanel.Dock="Bottom"
Text="{Binding ElementName=lstBreaks, Path=SelectedItem.ID, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="2" Grid.Column="1"/>
<TextBox Name="txtBreakTitle" DockPanel.Dock="Bottom"
Text="{Binding ElementName=lstBreaks, Path=SelectedItem.Title, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="2" Grid.Column="2"/>
<ComboBox Name="cbxBreakType" DockPanel.Dock="Bottom"
Text="{Binding ElementName=lstBreaks, Path=SelectedItem.Description, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="2" Grid.Column="3"/>
</StackPanel>
</Grid>
</Window>
using System;
using System.Data;
using System.Windows;
using System.Windows.Controls;
namespace WpfApplication2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
CreateData();
this.DataContext = Data;
}
public DataSet Data { get; set; }
private void CreateData()
{
Data = new DataSet();
Data.Tables.Add(CreateJobTable());
Data.Tables.Add(CreateSessionsTable());
Data.Tables.Add(CreateBreaks());
DataRelation relation = GetJobSessionRelations();
DataRelation relation2 = GetSessionBreakRelations();
Data.Relations.AddRange(new[] {relation, relation2});
}
private DataTable CreateJobTable()
{
var jobs = new DataTable();
jobs.TableName = "JobDetails";
var col1 = new DataColumn("ID");
var col2 = new DataColumn("Title");
var col3 = new DataColumn("Description");
col1.DataType = Type.GetType("System.Int32");
col2.DataType = Type.GetType("System.String");
col3.DataType = Type.GetType("System.String");
jobs.Columns.Add(col1);
jobs.Columns.Add(col2);
jobs.Columns.Add(col3);
DataRow row = jobs.NewRow();
row["ID"] = 1;
row["Title"] = "Job 1";
row["Description"] = "Job Desc 1";
jobs.Rows.Add(row);
DataRow row2 = jobs.NewRow();
row2["ID"] = 2;
row2["Title"] = "Job 2";
row2["Description"] = "Job Desc 2";
jobs.Rows.Add(row2);
return jobs;
}
private DataTable CreateSessionsTable()
{
var sessions = new DataTable();
sessions.TableName = "SessionDetails";
var col1 = new DataColumn("ID");
var col2 = new DataColumn("Title");
var col3 = new DataColumn("Description");
var col4 = new DataColumn("JobID");
col1.DataType = Type.GetType("System.Int32");
col2.DataType = Type.GetType("System.String");
col3.DataType = Type.GetType("System.String");
col4.DataType = Type.GetType("System.Int32");
sessions.Columns.Add(col1);
sessions.Columns.Add(col2);
sessions.Columns.Add(col3);
sessions.Columns.Add(col4);
DataRow row = sessions.NewRow();
row["ID"] = 1;
row["Title"] = "Session 1";
row["Description"] = "Session Desc 1";
row["JobID"] = 1;
sessions.Rows.Add(row);
DataRow row2 = sessions.NewRow();
row2["ID"] = 2;
row2["Title"] = "Session 2";
row2["Description"] = "Session Desc 2";
row2["JobID"] = 1;
sessions.Rows.Add(row2);
DataRow row3 = sessions.NewRow();
row3["ID"] = 3;
row3["Title"] = "Session 3";
row3["Description"] = "Session Desc 3";
row3["JobID"] = 2;
sessions.Rows.Add(row3);
DataRow row4 = sessions.NewRow();
row4["ID"] = 4;
row4["Title"] = "Session 4";
row4["Description"] = "Session Desc 4";
row4["JobID"] = 2;
sessions.Rows.Add(row4);
return sessions;
}
private DataTable CreateBreaks()
{
var breaks = new DataTable();
breaks.TableName = "BreakDetails";
var col1 = new DataColumn("ID");
var col2 = new DataColumn("Title");
var col3 = new DataColumn("Description");
var col4 = new DataColumn("SessionID");
col1.DataType = Type.GetType("System.Int32");
col2.DataType = Type.GetType("System.String");
col3.DataType = Type.GetType("System.String");
col4.DataType = Type.GetType("System.Int32");
breaks.Columns.Add(col1);
breaks.Columns.Add(col2);
breaks.Columns.Add(col3);
breaks.Columns.Add(col4);
DataRow row = breaks.NewRow();
row["ID"] = 1;
row["Title"] = "Break 1";
row["Description"] = "Break Desc 1";
row["SessionID"] = 1;
breaks.Rows.Add(row);
DataRow row2 = breaks.NewRow();
row2["ID"] = 2;
row2["Title"] = "Break 2";
row2["Description"] = "Break Desc 2";
row2["SessionID"] = 2;
breaks.Rows.Add(row2);
DataRow row3 = breaks.NewRow();
row3["ID"] = 3;
row3["Title"] = "Break 3";
row3["Description"] = "Break Desc 3";
row3["SessionID"] = 3;
breaks.Rows.Add(row3);
DataRow row4 = breaks.NewRow();
row4["ID"] = 4;
row4["Title"] = "Break 4";
row4["Description"] = "Break Desc 4";
row4["SessionID"] = 4;
breaks.Rows.Add(row4);
return breaks;
}
private DataRelation GetSessionBreakRelations()
{
return new DataRelation("relJobDetailsSessionDetails", Data.Tables["JobDetails"].Columns["ID"],
Data.Tables["SessionDetails"].Columns["JobID"]);
}
private DataRelation GetJobSessionRelations()
{
var dataRelation = new DataRelation("relSessionDetailsBreakDetails", Data.Tables["SessionDetails"].Columns["ID"],
Data.Tables["BreakDetails"].Columns["SessionID"]);
return dataRelation;
}
private void lstJobs_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
private void lstSessions_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
private void lstBreaks_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
}
}