希望有人能夠闡明我的問題。我跟着在這裏找到的教程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