• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

datagrid says there are no columns, when it displays columns

GoingUp

Lifer
I am trying to get a message to pop up when there are no successful search results that says "item not found"

here is my code
Sql = "SELECT Product_no, Name, Description, Unit_price, Qty_in_stock, Notes FROM PRODUCT WHERE PRODUCT_no ='" & value & "'"
Cmd = New OleDb.OleDbCommand(Sql, Con)

Con.Open()


Reader = Cmd.ExecuteReader(CommandBehavior.CloseConnection)
datagrid.DataSource = Reader
datagrid.DataBind()
If datagrid.Columns.Count.Equals(0) Then
lblstatus.Text = "Item not found. Please try again."
End If

Con.Close()

No matter what I do, columns.count always equals 0 no matter what. Even if I do a succesful search and a 5 columned datagrid appears, columns count = 0. Ideas? I just want to display the erro if nothing shows up.
 
that didnt work.

I did get this to work though.

lblstatus.Text = ""
If datagrid.Items.Count.Equals(0) Then
lblstatus.Text = "Item not found. Please try again."
End If
 
Back
Top