DataGrid binding problem


Sep 12, 2005
Programming Experience
Hello Everyone
I am building a sales register with VB.NET and SQL. I have a datagrid which displays all the items to be sold. It is bound to a dataset. The grid Displays an item on a button click which passes the product Id. I can have multiple items displayed on the grid. Now the problem is that I need a way to find out if a given item is already displayed in the grid. If it is displayed already I don't want to put a new entry in the grid, instead I want to add a new column in the grid named 'Quantity 'and have the 'Quantity' show how many that times that item is called.
Below is the code I have for showItem(). showItem() is called by the button click.

private Sub showItem()
Dim constr As String = "Persist Security Info=True;Initial Catalog=c450bzsingh;Data Source=CSCSQL;User Id=c450bzsingh;Password=241208"
Dim sqlConn As New SqlConnection(constr)
Dim sqlComm As New SqlCommand("spDisplayItem", sqlConn)

sqlComm.CommandType = CommandType.StoredProcedure
sqlComm.Parameters.Add("@ID", TextBox1.Text)
Dim DA As New SqlDataAdapter(sqlComm)
If DA.Fill(DS, "Inventory") Then

DataGrid1.SetDataBinding(DS, "Inventory")
System.Windows.Forms.MessageBox.Show("Not Valid ID")
End If
End Sub

Hope this helps

Thanks for your time.

Top Bottom