希望有人能够阐明我的问题。我跟着在这里找到的教程http://msdn.microsoft.com/en-us/library/ms171925(v=VS.100).aspx#Y3500,无法得到这个工作。从datagridview传递数据以形成C#
我的代码如下:
namespace CityCollectionCSharp
{
public partial class frmSwitch : Form
{
public frmSwitch()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'newCityCollectionDataSet.ClientTable' table. You can move, or remove it, as needed.
this.clientTableTableAdapter.Fill(this.newCityCollectionDataSet.ClientTable);
// TODO: This line of code loads data into the 'newCityCollectionDataSet.PropertyInformation' table. You can move, or remove it, as needed.
this.propertyInformationTableAdapter.Fill(this.newCityCollectionDataSet.PropertyInformation);
}
private void propertyInformationDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
System.Data.DataRowView SelectedRowView;
newCityCollectionDataSet.PropertyInformationRow SelectedRow;
SelectedRowView = (System.Data.DataRowView)propertyInformationBindingSource.Current;
SelectedRow = (newCityCollectionDataSet.PropertyInformationRow)SelectedRowView.Row;
frmSummary SummaryForm = new frmSummary();
SummaryForm.LoadCaseNumberKey(SelectedRow.CaseNumberKey);
SummaryForm.Show();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
propertyInformationBindingSource.Filter = "ClientKey ='" + comboBox1.SelectedValue + "'";
}
}
}
这是第一种形式,现在的第二种形式:
namespace CityCollectionCSharp
{
public partial class frmSummary : Form
{
public frmSummary()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'newCityCollectionDataSet.PropertyInformation' table. You can move, or remove it, as needed.
this.propertyInformationTableAdapter.Fill(this.newCityCollectionDataSet.PropertyInformation);
}
internal void LoadCaseNumberKey(String CaseNumber)
{
propertyInformationTableAdapter.FillByCaseNumberKey(newCityCollectionDataSet.PropertyInformation, CaseNumber);
}
}
}
我有查询设置为在propertyInfromationTableAdapter如下:
SELECT CaseNumberKey, BRTNumber, ParcelNumber, Premises, ClientKey, ParcelNum, Registry, TaxAcctName, StreetCode, CoverDate, OrderDate, Assessment, TaxFrom, TaxTo, TaxOpen, WaterOpen, WaterAcct, WaterTo, WaterFrom, AssessedBeg, AssessedDim, SumNotes, Legal, TotalWater, TotalTax, Type, OPARec, OPADoc, OPADocNum, Recital, Num, Name, Direction, Unit, ProductKey, DateFinished, Finished, Paid, BD, BDPaid, Search, Exam
FROM PropertyInformation
WHERE (CaseNumberKey = @CaseNumberKey)
我无法弄清楚我的生活为什么这不按照规定工作。当我点击一条记录时,它会在表格中传递两个记录,并始终在我有的第一个记录中。当我离开绑定导航器时,我只知道这一点。任何帮助将非常感激。
我想出了这笔交易是什么。有一行代码填充自动插入的视图,并覆盖查询。我删除了类似this.propertyInformationTableAdapter.Fill(this.newCityCollectionDataSet.PropertyInformation)的代码行;它解决了问题! – korrowan 2011-03-10 13:22:35