Avatar of navinbabu
navinbabu
Flag for India asked on

How to force a datagrid to display with no data

Hello guys ,

I have a datagrid with autogenerate = false . which is populated based on the previous datagrid . Now , in the second grid I have a text box and insert command to insert in to the grid . But I want to show the grid even its empty so that I can use the insert functionality to add new records


Thanks
.NET ProgrammingASP.NETVisual Basic Classic

Avatar of undefined
Last Comment
Reza Rad

8/22/2022 - Mon
Reza Rad

Reza Rad

Also you can use EmptyDataTemplate, like this:
<asp:GridView ID="GridView1" runat="server">
            <EmptyDataTemplate>
                There is no data.
            </EmptyDataTemplate>
        </asp:GridView>

navinbabu

ASKER
Hello reza_rad ,

thanks but can I make it visible only up on the first grid index selection
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ajitha75

The GridView has ShowHeaderWhenEmpty property.

Set it to true, to show only the headers
ASKER CERTIFIED SOLUTION
Reza Rad

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
navinbabu

ASKER
Reza rad .

here is a screen shot

http://img237.imageshack.us/img237/3055/69420553.png 


the status and remarks grid are populated up on the selecting in the first grid . Now in the remarks grid we have add option right .

I want that to be displayed even when the remarks grid is empty so that users can add one remarks

I hope I'm clear

Reza Rad

could you upload you image here?
I can not see the link you referred
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
navinbabu

ASKER
Reza red I m attaching the image
69420553.png
Reza Rad

try like this:
use EmptyDataTemplate like this:

<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
            <EmptyDataTemplate>
                 Empty table. click on this button to insert new record
                <asp:Button ID="Button1" runat="server" Text="Add" onclick="Button1_Click" />
            </EmptyDataTemplate>
        </asp:GridView>
navinbabu

ASKER
when we use emptydata template it is displayed even before its populated as I said this is populated based up on the selection on first grid .
Your help has saved me hundreds of hours of internet surfing.
fblack61
Reza Rad

use emptydatatemplate with combination of first grid selectionIndexchanged event as i said in this post: 26769825

does it make sense to you?
if not, upload your code here