Harshit
Harshit

Reputation: 62

How to show NULL value using GridView in asp.net?

I am using gridview to fetch the data from sqlserver. there are few values which are NULL. How to show these values using Gridview?

Upvotes: 0

Views: 2902

Answers (2)

Neeraj Sharma
Neeraj Sharma

Reputation: 588

May be this will help you,

 <asp:GridView ID="id" runat="server" CellPadding="4">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>                          
                            <%# Convert.ToString(Eval("columnName")) == null ? 'any text you want to write' : Eval("columnName") %>                         
                    </ItemTemplate>                     
                </asp:TemplateField>
</asp:GridView>

Upvotes: 0

Sateesh Pagolu
Sateesh Pagolu

Reputation: 9606

As per your feedback in comments, use this..

SELECT ISNULL(ColumnName, 'NULL')

Upvotes: 2

Related Questions