I'm trying to retrieve columns based on their corresponding key.
"Select * from diamond where p_Id="+p_Id
I followed MSDN sample and they were doing it like this way:
CurrencyManager cm = ((CurrencyManager)this.BindingContext[myDatabaseDataSet, "Items.ItemDiamond"]);
IBindingList list = (IBindingList)cm.List;
but list's related view data only returns data of p_Id=1. What's wrong?.
Full Code:
private void Viewdiamonds(int p_Id)
{
this.Cursor = Cursors.WaitCursor;
frmDiamond frmd = new frmDiamond();
CurrencyManager cm = ((CurrencyManager)this.BindingContext[myDatabaseDataSet, "Items.ItemDiamond"]);
IBindingList list = (IBindingList)cm.List;
frmd.ShowDialog(p_Id, this, list);
this.Cursor = Cursors.Default;
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 1 && e.RowIndex != -1 && !dataGridView1.Rows[e.RowIndex].IsNewRow)
{
DataGridViewCell cell = this.dataGridView1[e.ColumnIndex - 1, e.RowIndex];
int p_Id = Convert.ToInt32(cell.Value);
this.Viewdiamonds(p_Id);
}
}
Edit:
I've two related columns, Items and Diamond. I've a datagridview control that display data from Items table. I added a column of type LinkView, so when the user clicks ViewDiamond, a new form pops up and display Diamonds related to that Item. I looked at MSDN DataGridView control sample, and they implemented that using the code above. I did some tweaks to the code to fit my application. What's the wrong with the code above? Because it seems its not able to display the data according to its relative p_Id. Or I think there is somthing wrong with the p_Id, no matter its value, Currency manager seems to retrieve only data corresponed to p_Id = 1.
I hope this clarified the issue.