Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8917607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:31:52+00:00 2026-06-15T05:31:52+00:00

I’m building a GridView based on what is passed on the previous page querystring.

  • 0

I’m building a GridView based on what is passed on the previous page querystring.

Is there a way to display a message saying ‘no records found’ if the GridView isn’t populated? i.e. the query produces no records to populate the GridView.

code:

<div class="centergrid">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSource1" CssClass="bookgridview">
        <Columns>
            <asp:TemplateField HeaderText="Choose">
            <ItemTemplate>
                 <asp:HyperLink ID="lnkSelect" runat='server' NavigateUrl='<%# String.Format("~/bookingform.aspx?ID={0}", Eval("ScheduleId")) %>'>Book</asp:HyperLink>
            </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="TName" HeaderText="Name" SortExpression="TName" />
            <asp:BoundField DataField="SDate" HeaderText="Date" SortExpression="SDate" DataFormatString="{0:d}" />
            <asp:BoundField DataField="STime" HeaderText="Time" SortExpression="STime" />
            <asp:BoundField DataField="TPriceadult" HeaderText="Price (Adult)" 
                SortExpression="TPriceadult" DataFormatString="{0:C}"  /> 
            <asp:BoundField DataField="TPricesenior" HeaderText="Price (Student/Senior)" 
                SortExpression="TPricesenior" DataFormatString="{0:C}"  /> 
            <asp:BoundField DataField="TPricechild" HeaderText="Price (Child)" 
                SortExpression="Tpricechild" DataFormatString="{0:C}"   /> 
            <asp:BoundField DataField="TDuration" HeaderText="Duration"
                SortExpression="TDuration" />
            <asp:BoundField DataField="ScheduleId" HeaderText="ScheduleId" 
                SortExpression="ScheduleId"  Visible="False" />
        </Columns>
    </asp:GridView>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ChinatowndbConnString %>" 
        SelectCommand="SELECT * FROM [vwSchedule] Where TourId=@tid">

        <SelectParameters>
            <asp:QueryStringParameter DbType="Int32" Name="tid" QueryStringField="tourid" />
        </SelectParameters>
    </asp:SqlDataSource>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:31:53+00:00Added an answer on June 15, 2026 at 5:31 am

    Is there a way to display a message saying ‘no records found’ if the
    GridView isn’t populated?

    Yes, with the EmptyDataTemplate.

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSource1" CssClass="bookgridview">
    
        <emptydatarowstyle backcolor="LightBlue"
          forecolor="Red"/>
    
        <emptydatatemplate>
    
          <asp:image id="NoDataImage"
            imageurl="~/images/Image.jpg"
            alternatetext="No Image" 
            runat="server"/>
    
            No records found.  
    
        </emptydatatemplate> 
    
        <Columns>
            <asp:TemplateField HeaderText="Choose">
            <ItemTemplate>
                 <asp:HyperLink ID="lnkSelect" runat='server' NavigateUrl='<%# String.Format("~/bookingform.aspx?ID={0}", Eval("ScheduleId")) %>'>Book</asp:HyperLink>
            </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="TName" HeaderText="Name" SortExpression="TName" />
            <asp:BoundField DataField="SDate" HeaderText="Date" SortExpression="SDate" DataFormatString="{0:d}" />
            <asp:BoundField DataField="STime" HeaderText="Time" SortExpression="STime" />
            <asp:BoundField DataField="TPriceadult" HeaderText="Price (Adult)" 
                SortExpression="TPriceadult" DataFormatString="{0:C}"  /> 
            <asp:BoundField DataField="TPricesenior" HeaderText="Price (Student/Senior)" 
                SortExpression="TPricesenior" DataFormatString="{0:C}"  /> 
            <asp:BoundField DataField="TPricechild" HeaderText="Price (Child)" 
                SortExpression="Tpricechild" DataFormatString="{0:C}"   /> 
            <asp:BoundField DataField="TDuration" HeaderText="Duration"
                SortExpression="TDuration" />
            <asp:BoundField DataField="ScheduleId" HeaderText="ScheduleId" 
                SortExpression="ScheduleId"  Visible="False" />
        </Columns>
    </asp:GridView>
    

    Alternatively, you can use the built-in UI for the empty data row by setting the EmptyDataText property instead of this property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I am trying to understand how to use SyndicationItem to display feed which is
I have a small JavaScript validation script that validates inputs based on Regex. I
In my XML file chapters tag has more chapter tag.i need to display chapters
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.