Link to home
Start Free TrialLog in
Avatar of navinbabu
navinbabuFlag 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
Avatar of Reza Rad
Reza Rad
Flag of New Zealand image

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

Avatar of navinbabu

ASKER

Hello reza_rad ,

thanks but can I make it visible only up on the first grid index selection
The GridView has ShowHeaderWhenEmpty property.

Set it to true, to show only the headers
ASKER CERTIFIED SOLUTION
Avatar of Reza Rad
Reza Rad
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

could you upload you image here?
I can not see the link you referred
Reza red I m attaching the image
69420553.png
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>
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 .
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