簡體   English   中英

Gridview中的數據為空,行未顯示

[英]Empty data in Gridview , rows not showing

我有一個GridView具有5列的數據和兩列為空。 還有一個編輯按鈕,我可以編輯每一行。 只有在按下按鈕Edit並將數據添加到表單並完成后,兩列才會不再為空。 我怎樣才能做到這一點 ? 我嘗試將EmptyDataText與“無數據”一起使用,但是它不起作用。

我的GridView沒有顯示包含空數據的行。

我正在使用ASP.NET C#

<asp:GridView ID="GridViewSO" runat="server" DataSourceID="SqlDataSourceShippingOffice" AutoGenerateColumns="False" OnRowDataBound="GridViewSO_RowDataBound" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" Font-Names="Calibri" Font-Size="8pt" EmptyDataText="No data" >
    <AlternatingRowStyle BackColor="#DCDCDC"></AlternatingRowStyle>
    <Columns>
        <asp:TemplateField HeaderText="Nr. crt.">
            <ItemTemplate>
                <%# Container.DataItemIndex + 1 %>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="P_ID" HeaderText="P.ID" SortExpression="ID" />
        <asp:BoundField DataField="S_ID" HeaderText="S.ID" SortExpression="ID1" />
        <asp:BoundField DataField="DATE" HeaderText="Date" SortExpression="DATE" />
        <asp:BoundField DataField="PLACE" HeaderText="Place" SortExpression="PLACE" />
        <asp:BoundField DataField="DATE_U" HeaderText="DateU" SortExpression="DATE_U" />
        <asp:BoundField DataField="TYPE" HeaderText="Type" SortExpression="TYPE" />
        <asp:BoundField DataField="CAR" HeaderText="Car" SortExpression="CAR" />
        <asp:BoundField DataField="EH" HeaderText="EH" SortExpression="EH" />
        <asp:BoundField DataField="COND" HeaderText="Cond" SortExpression="COND" />
        <asp:BoundField DataField="NAME" HeaderText="Name" SortExpression="NAME" />
        <asp:BoundField DataField="REFERENT" HeaderText="Referent" ReadOnly="True" SortExpression="REFERENT" />
        <asp:TemplateField HeaderText="Nr Form">
            <ItemTemplate>
                <asp:TextBox ID="txtSOGV" runat="server" Enabled="False" Rows="4" TextMode="MultiLine" Style="overflow: auto" Height="45px" Width="64px"></asp:TextBox>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:Button ID="btnEditSO" runat="server" Text="Edit" OnClick="btnEditSO_Click" CausesValidation="False" />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="ID" HeaderText="REF_ID" SortExpression="ID" />

    </Columns>
    <EmptyDataRowStyle BackColor="#CCCCFF" Font-Bold="True" ForeColor="#FF3300" />
    <FooterStyle BackColor="#CCCCCC" ForeColor="Black"></FooterStyle>

    <HeaderStyle BackColor="#000084" Font-Bold="False" ForeColor="White" Font-Size="12pt"></HeaderStyle>

    <PagerStyle HorizontalAlign="Center" BackColor="#999999" ForeColor="Black"></PagerStyle>

    <RowStyle BackColor="#EEEEEE" ForeColor="Black"></RowStyle>

    <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White"></SelectedRowStyle>

    <SortedAscendingCellStyle BackColor="#F1F1F1"></SortedAscendingCellStyle>

    <SortedAscendingHeaderStyle BackColor="#0000A9"></SortedAscendingHeaderStyle>

    <SortedDescendingCellStyle BackColor="#CAC9C9"></SortedDescendingCellStyle>

    <SortedDescendingHeaderStyle BackColor="#000065"></SortedDescendingHeaderStyle>
</asp:GridView>

這是我的GridView。 並且只有“引用人”和“ Nr表格”將首先為空。

添加ShowHeaderWhenEmpty="true"在你gridview

注意:除非使用非null的值調用DataBind()否則標題不會出現。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM