Replacing text on page

Last post 08-12-2008 12:43 PM by im1dermike. 5 replies.

Sort Posts:

  • Replacing text on page

    08-12-2008, 11:17 AM
    • Member
      37 point Member
    • im1dermike
    • Member since 06-12-2008, 11:35 AM
    • Posts 314

    I have a Content window on a page where I have a handful of gridviews and also plain text I'm using above them as labels.  Sometimes, depending on whether of not there is data, some gridviews may not appear.  In this case, I want to have "N/A" displayed under the label.

    Currently I have it set up so that I have the following text above the gridview to as as a label:

    "Enrollments: XXX"

    What I'm intending to do is if there is no data for the grid, replace "XXX" with "<BR>N/A".  If there is data, I'll just replace it with an empty string.  I don't know how to replace the text, though, being that it's not part of a textbox, but rather just located within a content item.

     

    Please advise.  Thanks.
     

  • Re: Replacing text on page

    08-12-2008, 11:27 AM
    Answer
    • Star
      12,651 point Star
    • docluv
    • Member since 06-29-2002, 11:16 PM
    • Willow Spring NC
    • Posts 2,003
    • TrustedFriends-MVPs

    Add an EmptyDateTemplate to your grid.

    <EmptyDataTemplate>
     Sorry, there are no Articles Available at this time.

    </EmptyDataTemplate>

  • Re: Replacing text on page

    08-12-2008, 11:38 AM
    • Member
      37 point Member
    • im1dermike
    • Member since 06-12-2008, 11:35 AM
    • Posts 314

     Can you explain in a little more detail?  I just started programming in ASP.net a couple days ago.

  • Re: Replacing text on page

    08-12-2008, 12:27 PM
    • Member
      244 point Member
    • may.23.2007
    • Member since 08-06-2008, 6:54 PM
    • Posts 47

     You could use something like this:

     <asp:GridView id="gvTest" runat="server" EmptyDataText="N/A" > </asp:GridView>

      
  • Re: Replacing text on page

    08-12-2008, 12:41 PM
    Answer
    • Participant
      957 point Participant
    • sugan.v
    • Member since 06-10-2008, 12:37 AM
    • Posts 185

    Hi,

    In your GridView code, (in your source code file) between <GridView>......... </GridView)

    <EmptyDataTemplate>

    No Data available

    </EmptyDataTemplate>

    As show below, (You GridView may have some different than this).

     

     

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"

    DataKeyNames="ID" DataSourceID="SqlDataSource1">

    <Columns>

    <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"

    ReadOnly="True" SortExpression="ID" />

    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />

    </Columns>

    <EmptyDataTemplate>

    No data Available

    </EmptyDataTemplate>

    </asp:GridView>

    I hope this will help you,

    -Sugan

    Remember to click “Mark as Answer” on the post If you get answer from this post(s) !
  • Re: Replacing text on page

    08-12-2008, 12:43 PM
    • Member
      37 point Member
    • im1dermike
    • Member since 06-12-2008, 11:35 AM
    • Posts 314

     Awesome.  Thanks a lot guys.

Page 1 of 1 (6 items)