0

I have a GridView with 5 columns with data and two columns empty. And a button Edit which I can edit every row. Only after I push the Button Edit and add data to the form and finish the two columns will not be empty anymore. How can I do that ? I tried with EmptyDataText with "No data" but it doesn't work.

My GridView is not showing the rows with empty data.

I am using 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>

This is my GridView. And only the Referent and the Nr Form will be empty first.

2
  • 1
    Provide some code to show what you have already Commented Jul 15, 2015 at 6:54
  • 1
    No one can help you without code. Please show your code. Commented Jul 15, 2015 at 6:54

1 Answer 1

1

Add ShowHeaderWhenEmpty="true" in your gridview

Note: the headers will not appear unless DataBind() is called with something other than null.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes I know, but I don't want to show only the Header. I want to show all the fields and that two fields which are first null after Edit and adding something to the form to fill
After you edit the column and add data to it, then it will show. Actually your question is unclear. Can you be more specific what's your question or problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.