0

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

8
  • 3
    in sql server you can do something like SELECT ISNULL(ColumnName, 'no value') Commented Aug 10, 2015 at 11:54
  • how do you want to display them? as the word "NULL", a blank, etc? Commented Aug 10, 2015 at 11:56
  • Yes! but how to do it using asp.net to show on a webpage? Commented Aug 10, 2015 at 11:56
  • As a NULL...... @psoshmo Commented Aug 10, 2015 at 11:57
  • Do you want handle nulls on sql server side or in c#? if either one is fine, Ali's comment is answer. Commented Aug 10, 2015 at 11:57

2 Answers 2

2

As per your feedback in comments, use this..

SELECT ISNULL(ColumnName, 'NULL')
Sign up to request clarification or add additional context in comments.

Comments

0

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>

1 Comment

you are converting it to string and comparing with keyword Null. dont you see an issue?

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.