【问题标题】:footer template display in grid页脚模板在网格中显示
【发布时间】:2011-10-08 13:17:15
【问题描述】:

我有一个页脚模板,它会将文本框附加到网格中。即使网格中没有数据,我也想显示页脚模板。

 <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>    

这是我的网格

【问题讨论】:

    标签: c# asp.net gridview


    【解决方案1】:

    将网格的 EmptyDataText 设置为网格为空时要使用的文本

    【讨论】:

    • 在这种情况下,我将获得具有价值的网格。我只需要附加空文本框。我得到了一个解决方案,例如在绑定到网格之前添加一个虚拟值并使其可见并在单击添加后再次删除它
    猜你喜欢
    • 1970-01-01
    • 2010-10-10
    • 2011-03-27
    • 2015-03-13
    • 2019-03-09
    • 1970-01-01
    • 2015-03-13
    • 1970-01-01
    • 2013-01-01
    相关资源
    最近更新 更多