Below is my coding on the query extender control… all working fine but if i want to show a prompt up message said if no record found?
what should i do ? how to do it ?
Coding(HolidaySearch.aspx)
<%@ Page Title="" Language="C#" MasterPageFile="~/SiteAdmin.Master" AutoEventWireup="true" CodeBehind="HolidaySearch.aspx.cs" Inherits="TimeAttendReport.Account.HolidaySearch" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> <style type="text/css"> .style3 { width: 766px; } .style4 { width: 100%; } .style5 { width: 200px; } </style> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <div> <h2 style="color: Blue"> Holiday Search:</h2> </div> <table class="style4"> <tr> <td class="style5"> Holiday Search:</td> <td> </td> <td> </td> </tr> <tr> <td class="style5"> </td> <td> </td> <td> </td> </tr> <tr> <td class="style5"> Holiday Name:</td> <td> <asp:TextBox ID="txtHoliday" runat="server" Height="22px" Width="221px"></asp:TextBox> </td> <td> </td> </tr> <tr> <td class="style5"> </td> <td> <asp:Button ID="Button2" runat="server" Text="Search" /> </td> <td> </td> </tr> </table> <div> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataSourceID="LinqDataSource1" ForeColor="#333333" GridLines="None" PageSize="8" Width="531px" style="text-align: center; background-color: #0000FF;"> <AlternatingRowStyle BackColor="White" /> <Columns> <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" /> <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" InsertVisible="False" /> <asp:BoundField DataField="Holiday1" HeaderText="Holiday1" SortExpression="Holiday1" /> <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" /> <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" /> </Columns> <EditRowStyle BackColor="#2461BF" /> <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="#EFF3FB" /> <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> <SortedAscendingCellStyle BackColor="#F5F7FB" /> <SortedAscendingHeaderStyle BackColor="#6D95E1" /> <SortedDescendingCellStyle BackColor="#E9EBEF" /> <SortedDescendingHeaderStyle BackColor="#4870BE" /> </asp:GridView> <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="TimeAttendReport.App_Code.DataClasses1DataContext" EnableDelete="True" EnableInsert="True" EnableUpdate="True" EntityTypeName="" TableName="Holidays"> </asp:LinqDataSource> <asp:QueryExtender ID="QueryExtender1" runat="server" TargetControlID="LinqDataSource1"> <asp:SearchExpression DataFields="Holiday1" SearchType ="StartsWith"> <asp:ControlParameter ControlID = "txtHoliday" /> </asp:SearchExpression> </asp:QueryExtender> </div> </asp:Content>
In Server side (C#) during gridview databind you can check if datatsource is empty means no records you can show message or
Use the GridView Empty Data Template. See the example here:
the GridView dislay its EmptyTemplate content if there is no data , you can configure the gridView to Display that message by setting theEmptyDataTemplate of the
gridview as foolwos :
<asp:GridView ID="GridView1" runat="server"> <EmptyDataTemplate> No Data Exists </EmptyDataTemplate> <Columns > ...... </Columns> </asp:GridView>