Datagridview showing unbound records
<p>I need some help with code for a datagridview. It currrently shows data from a table which is not databound. When they search for a particular item it should only display that item and the user can then change the quantity cell.</p>

<p>On clicking of a button to view the entire set of data based on a particular field, it should show all the rows including the ones that the quantity cell has been changed.</p>

<p>How do I achieve showing only the selected row and on clicking 'view all' button, show the whole set of records that has not been saved anywhere yet?</p>

<p>Thanks in advance.</p>

<pre><code>string BarCode = null;
                SAPbobsCOM.Recordset oRec = null;
                oRec = (SAPbobsCOM.Recordset)MainModule.company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                oRec.DoQuery("SELECT " +
                    "T0.[ItemCode] FROM [dbo].[OITM]  " +
                    "T0 WHERE T0.[CodeBars] = '" + textBoxBarCode.Text + "' " +
                        "OR T0.[U_bcode2] = '" + textBoxBarCode.Text + "' " +
                        "OR T0.[U_bcode3] = '" + textBoxBarCode.Text + "' " +
                        "OR T0.[U_bcode4] = '" + textBoxBarCode.Text + "'");

                if (oRec.RecordCount &gt; 0)
                {
                    BarCode = oRec.Fields.Item("ItemCode").Value.ToString();
                }

                foreach (DataGridViewRow r in dataGridViewDetails.Rows)
                {
                    r.Selected = false;
                    if (!r.IsNewRow)
                    {
                        int rowIndex = -1;

                        if (r.Cells["ItemCode"].Value.ToString().Equals(BarCode))
                        {
                            rowIndex = r.Index;
                            r.Selected = true;
                            break;
                        }
                    }
                }
</code></pre>
