| |

VerySource

 Forgot password?
 Register
Search
View: 1205|Reply: 7

The GridView control displays nicely when there is data in the data source, but once there is no record, it is empty and

[Copy link]

7

Threads

16

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

Post time: 2020-2-22 09:30:01
| Show all posts |Read mode
Can it be shown when the data source record is zero? Otherwise, it looks uncomfortable as if the control does not exist.
Reply

Use magic Report

0

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-5-3 20:45:01
| Show all posts
If the returned value is NULL, bind a new DataTable object
DataView.DataSource = new Datatable ()
DataView.Databind ();
Or put the data source. Clear ();
Because the null value is the Count of the data source is not, not 0, is not
When you Clear (), the Count property value of the object becomes 0, then the binding will also display the table header
Reply

Use magic Report

0

Threads

25

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-5-3 21:15:01
| Show all posts
<asp: gridview ....>
<emptydatatemplate>
<asp: label ...>
There is no data to show in this view.
</ asp: label>
</ emptydatatemplate>
</ asp: gridview>
Reply

Use magic Report

0

Threads

25

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-5-4 09:15:01
| Show all posts
The above code adds an emptydatatemplate template,
Prompt message is displayed when the data source is empty, the template is ignored if it is not empty
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Invalid IP Address

Post time: 2020-6-7 19:45:01
| Show all posts
The second floor is wrong, I tried it for the landlord, no!
Reply

Use magic Report

0

Threads

25

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-7-4 09:15:01
| Show all posts
When the data source record is zero, the data source is empty!
There must be a data source.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-3 14:15:01
| Show all posts
I also have a problem like yours, but it seems there is no way. Finally, the attributes are added:
EmptyDataText="<div align=center><font color=red>There is no data you need</font></div>"
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-29 21:15:01
| Show all posts
Adding an empty record to the bound datatable is ok
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list