3
Answers

how to popup gridview from text box search in asp.net

Photo of jeenath kumar

jeenath kumar

5y
2.1k
1
hello..
Here, i attached my windows application image. when i press enter key the gridview will popup. I want this type of gridview popup search in asp.net.
please tell me
 
 

Answers (3)

4
Photo of Amit Mohanty
16 52.2k 6.1m 5y

Attachment WebApp1.zip

Try this.
 
Code for .aspx
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApp1.WebForm1" %>  
  2. <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>  
  3.   
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  5. <html xmlns="http://www.w3.org/1999/xhtml">  
  6. <head runat="server">  
  7.     <title>Popup Window</title>  
  8.     <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>  
  9.     <script type="text/javascript">  
  10.         $(function () {              
  11.             $('#txtname').keypress(function () {  
  12.                 ShowModalPopup();  
  13.             });  
  14.         });  
  15.   
  16.         function ShowModalPopup() {  
  17.             $find("mpe").show();  
  18.             return false;  
  19.         }  
  20.     </script>  
  21.     <style type="text/css">  
  22.         .tableBackground {  
  23.             background-color: silver;  
  24.             opacity: 0.7;  
  25.         }  
  26.     </style>  
  27. </head>  
  28. <body>  
  29.     <form id="form1" runat="server">  
  30.         <asp:ToolkitScriptManager ID="ScriptManager1" runat="server">  
  31.         </asp:ToolkitScriptManager>  
  32.         <div>  
  33.             <input id="txtname" runat="server"/>  
  34.                
  35.             <asp:LinkButton ID="lnkDummy" runat="server"></asp:LinkButton>  
  36.             <asp:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID="mpe" runat="server" TargetControlID="lnkDummy" PopupControlID="updatePanel"  
  37.                 BackgroundCssClass="tableBackground">  
  38.             </asp:ModalPopupExtender>  
  39.             <asp:Panel ID="updatePanel" runat="server" BackColor="White" Height="230px" Width="300px" Style="display: none">  
  40.                 <asp:GridView runat="server" ID="gridView1" DataKeyNames="id" AutoGenerateColumns="false" OnSelectedIndexChanged="gridView1_SelectedIndexChanged"  
  41.                     AutoGenerateSelectButton="True">  
  42.                     <Columns>  
  43.                         <asp:BoundField DataField="id" HeaderText="ID" />  
  44.                         <asp:BoundField DataField="name" HeaderText="NAME" />  
  45.                         <asp:BoundField DataField="education" HeaderText="EDUCATION" />  
  46.                         <asp:BoundField DataField="location" HeaderText="LOCATION" />  
  47.                     </Columns>  
  48.                 </asp:GridView>  
  49.             </asp:Panel>  
  50.         </div>  
  51.     </form>  
  52. </body>  
  53. </html> 
 Code For .cs
  1. using System;  
  2. using System.Data;  
  3.   
  4. namespace WebApp1  
  5. {  
  6.     public partial class WebForm1 : System.Web.UI.Page  
  7.     {  
  8.         protected void Page_Load(object sender, EventArgs e)  
  9.         {  
  10.             if (!IsPostBack)  
  11.             {  
  12.                 loadStores();  
  13.             }  
  14.         }  
  15.   
  16.         protected void loadStores()  
  17.         {  
  18.             // for making  Table     
  19.             DataTable dt = new DataTable();  
  20.   
  21.             // these are the table columns    
  22.             dt.Columns.Add("id"typeof(int));  
  23.             dt.Columns.Add("name"typeof(string));  
  24.             dt.Columns.Add("education"typeof(string));  
  25.             dt.Columns.Add("location"typeof(string));  
  26.   
  27.             // these are the table rows with values    
  28.             dt.Rows.Add(1, "Nilesh""B.E(IT)""Rajkot");  
  29.             dt.Rows.Add(2, "Purnima""B.E(CSE)""Rajkot");  
  30.             dt.Rows.Add(3, "Chandni""MSc(IT)""Ahmedabad");  
  31.             dt.Rows.Add(4, "Rinku""MBA""Pune");  
  32.             dt.Rows.Add(5, "Nilu""MBBS""Bikaner");  
  33.   
  34.             gridView1.DataSource = dt;  
  35.             gridView1.DataBind();  
  36.   
  37.         }  
  38.   
  39.         protected void gridView1_SelectedIndexChanged(object sender, EventArgs e)  
  40.         {  
  41.             txtname.Value = gridView1.SelectedRow.Cells[2].Text;  
  42.             ModalPopupExtender1.Hide();  
  43.         }  
  44.     }  

 
 
Accepted
2
Photo of Amit Mohanty
16 52.2k 6.1m 5y
Hey check the below links, this may help you.
 
https://www.aspsnippets.com/Articles/Display-GridView-Row-details-in-New-Popup-Window-on-HyperLink-click-using-JavaScript-and-jQuery-in-ASPNet.aspx
 
http://asp.net-informations.com/gridview/popup.htm
 
https://www.c-sharpcorner.com/UploadFile/009464/how-to-show-data-of-gridview-on-pop-up-with-the-help-of-rowd/
1
Photo of jeenath kumar
1.6k 66 3.9k 5y
Hi Amit mohanty
Thanks for reply
 
Great. it's working fine to me but small changes
 
 <asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
 
 
Once again Thank you so much