locked
Hyperlink on null values in a column. RRS feed

  • Question

  • User-1700168252 posted

    I have aspx grid view and i made one column as editable with hyperlink. When it have value it works good, but when it have the null value it doesnt work. The intention of whole logic is to bring up a pop up while clicking on the column value. I have done most of the coding , when i do a granular check i found this one doesnt work for null value. Can some one help me here to make the hyper link work for even null or empty value. This column value is fetched from sql database. 

    Below is my design code.

    <asp:TemplateField HeaderText="CR No" >
    <ItemTemplate>
    <asp:LinkButton ID="EditLinkButton" CausesValidation="false" runat="server" text= '<%#Eval("ControlNumber") %>' Fieldname='<%#Eval("WorkID")%>'
    ToolTip="Edit CR" CommandArgument='<%#Eval("WorkID") + ";" +Eval("ControlNumber") %>' OnClick="EditLinkButton_Click">
    </asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateField>

    Thursday, February 28, 2019 12:06 PM

Answers

  • User409696431 posted

    First, decide what you want the value to default to if the data is null.

    Then, test for null and replace it with what you want the default to be:

    <%#(Eval("Data") == null ? "0" : Eval("Data"))%>

    This example checks Data for null, returns 0 if it is null, and returns its value otherwise.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 1, 2019 4:59 AM

All replies

  • User409696431 posted

    First, decide what you want the value to default to if the data is null.

    Then, test for null and replace it with what you want the default to be:

    <%#(Eval("Data") == null ? "0" : Eval("Data"))%>

    This example checks Data for null, returns 0 if it is null, and returns its value otherwise.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 1, 2019 4:59 AM
  • User-1700168252 posted

    Thankyou Kathy it helps.:)

    Monday, March 4, 2019 8:56 PM