Hi,
I would suggest to show a label just above the data grid displaying the number of records searched. Popups can be used while validating the input for search or submit forms.
But if at all you want to display a popup if there are no records, you can use AjaxControlToolkit.
Download the tool kit from
http://ajaxcontroltoolkit.codeplex.com/[
^]
Add a reference of the tool kit dll to your ASP.Net project and to your page as (just below the @Page attribute)
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/MyTIO.Master" AutoEventWireup="true" CodeBehind="example.aspx.cs" Inherits="example.example.example" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
Add an asp:Panel (not displayed initially) for the message as below:
<asp:panel runat="server" id="pnlMessage" style="display:none" xmlns:asp="#unknown">
</asp:panel>
Format the panel in the CSS as you want.
Then, just below the search button, add a dummy button as follows:
<asp:button runat="server" id="btnSearchRecords" text="Search Records" onclick="btnSearchRecords_Click" xmlns:asp="#unknown" />
<asp:button runat="server" id="btnDummySearchRecords" style="display:none;" xmlns:asp="#unknown" />
Then add the ajax control tool kit modal popup extender as follows:
<asp:Button id="btnSearchRecords" Text="Search Records" onClick="btnSearchRecords_Click" />
<asp:Button id="btnDummySearchRecords" style="display:none;" />
<cc1:modalpopupextender id="mpeMessage" targetcontrolid="btnDummySearchRecords" backgroundcssclass="MessageBackground" xmlns:cc1="#unknown">
PopupControlID="pnlMessage"
OkControlID="btnClose"
DropShadow="true
</cc1:modalpopupextender>
In the button click event in c#, the code looks like as follows:
protected void btnSearchRecords_Click(object sender, EventArgs e)
{
DataTable searchedRecords = new DataTable();
searchedRecords = QueryDatabaseAndGetResults();
this.gvResults.DataSource = searchedRecords;
this.gvResults.DataBind();
if(searchRecords.Rows.Count == 0)
{
this.mpeMessage.show();
}
}
I hope this will help you with your question. Feel free to shoot out anything required.
Happy coding..!!
Cheers,
Nayan