premg
premg

Reputation: 1

footer template display in grid

I have a footer template which will append me text boxes to add to a grid. I want to display the footer template even if no data is present in grid.

 <asp:GridView AutoGenerateColumns="false"  EnableViewState="true" 
            ID="gvServiceGoalsAndFactors" runat="server" GridLines="None" BorderWidth="1" BorderColor="Brown"
            AlternatingRowStyle-BackColor="Cyan" HeaderStyle-BackColor="ActiveCaption" ShowFooter="true">              
            <Columns>                   
                <asp:TemplateField HeaderText= "Service Goal" >                     
                   <HeaderTemplate>Service(%)</HeaderTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                    <ItemTemplate>                        
                    <asp:Label ID="lblGoal" Visible="true" runat="server" Text='<%# Eval("Service") %>' />                                                                                   
                    </ItemTemplate>
                    <FooterTemplate>
                    <asp:TextBox ID="txtService" Style="margin-left: 350px" Visible='<%# IsInEditMode %>' runat="server" Text='<%#Eval("Service")%>' MaxLength="10">
                    </asp:TextBox>                                                            
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField >
                    <HeaderTemplate>Service Factor</HeaderTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                    <ItemTemplate>
                    <asp:Label ID="lblFactor" Visible='<%# ! IsInEditMode %>' runat="server" Text='<%# Eval("Factor") %>' />
                    <asp:TextBox ID="txtFactor" Visible='<%# IsInEditMode %>' runat="server" Text='<%#Eval("Factor")%>' MaxLength="10">
                        </asp:TextBox>                                    
                    </ItemTemplate>
                    <FooterTemplate>
                        <asp:TextBox ID="txtFactor" Style="margin-left: 218px" Visible='<%# IsInEditMode %>' runat="server" Text='<%#Eval("Factor")%>' MaxLength="10">
                        </asp:TextBox>                                    
                    </FooterTemplate>                        
                </asp:TemplateField>                   
            </Columns>                      
        </asp:GridView>    

This is my grid

Upvotes: 0

Views: 1232

Answers (1)

SMK
SMK

Reputation: 2158

Set EmptyDataText of grid to text which you want to use when grid is emmpty

Upvotes: 0

Related Questions