Last post Sep 29, 2017 05:56 AM by Cathy Zou
Sep 28, 2017 05:46 PM|dotnetcoder99|LINK
I have a gridview on a form. It's datasource is one of many table populated by a stored procedure. There is drop down that changes one parameters. In most cases, the default parameter brings back records but in the 2nd option it very well could return
no records. What I am seeing is that the datasource tables have no records but the gridview isn't rebinding. I have tried forcing the gridview to databind and it acts as if it does but the gridview returns the records from the first time though. Is there an
attribute in a gridview I am missing where I can tell it the datasource returned empty?
Sep 28, 2017 06:06 PM|mgebhard|LINK
The GridView has an
empty data template that you can use to display a message like "No Records Found". However, it sounds like you might a have bug in the code. Try using the Visual studio debugger to step through the logic or post the relevant bits if you need help debugging.
Sep 28, 2017 06:06 PM|gene7135|LINK
This might help....
I always set these 2 properties for a Gridview.
ShowHeaderWhenEmpty="true" EmptyDataText="No Assests Found"
Sep 28, 2017 07:29 PM|dotnetcoder99|LINK
OK, there might be a misunderstanding. i am aware of the emptydatatext attribute.
Just as a test to debug I placed this code at the end of the sub.
If dsData.Tables(7).Rows.Count = 0 Then
gv.Visible = False
When debugging, I see the count is zero and it says it sets the gridview to invisible but when the page renders, the gridview shows and it shows the original dataset values. Something is not getting set correctly.
Sep 28, 2017 07:54 PM|KathyW|LINK
We can't tell you what is happening, since you have showed no code. But first, use Visual Studio's debugger to find out when the gridview is actually being bound with the data it is showing. If you bind it to no data, and then it is subsequently, in the
page cycle, bound to different values before the page is rendered, it would explain why you don't see what you expect., as one possibility.
Sep 29, 2017 05:56 AM|Cathy Zou|LINK
Only from your description, it is hard for us to find the reason for your problem.
So, I suggest you could post related code of your problem so that we could reproduce your problem and find solution for you as soon as possible.