Ajaxloadprogressform.aspx:
<script src= "Js/jquery-1.4.2.js" type= "Text/javascript" ></script> <script type= "Text/javascript" > Function Showprogressdiv () {var ID = $ ("Input#idtxt"). Val (); $.ajax ({type: "GET", url: "Getgridviewbyconditionform. aspx ", Data:" id= "+ ID, beforesend:function () {$ (" Div#progressdiv "). CSS (" Display "," block ");}, Success:function (msg) {$ ("Div#showsearchresult"). HTML (msg);}, Complete:function () {$ ("Div#progressdiv"). CSS ("display", "none");;}); } </script> <form id= "Form1" runat= "Server" > <div> <input type= "text" id= "Idtxt" name= "Idtxt"/> <input type= "button" id= "loadbtn" value= "Loaddatagridview" onclick= "Showprogressdiv ()"/> </div> <div Id= "Progressdiv" style= "Display:none" > loading ... < /div> <div id= "Showsearchresult" > </div> </form>
Getgridviewbyconditionform.aspx:
protected void Page_Load (object sender, EventArgs e) {if (request["id"]! = null) {SqlConnection conn=null; SqlCommand cmd = null; SqlDataAdapter adapter = null; try {conn = new SqlConnection (); Conn. ConnectionString = configurationmanager.connectionstrings["NorthwindConnectionString"]. ConnectionString; Conn. Open (); cmd = new SqlCommand (); Cmd. Connection = conn; Cmd.commandtype = CommandType.Text; String cmdstr = "SELECT * FROM dbo. Customers "; if (request["id"). ToString ()!=string.empty) {cmdstr + = "where customerid= '" + request["id"]. ToString () + "'";} Cmd.commandtext = Cmdstr; adapter = new SqlDataAdapter (cmd); DataSet ds = new DataSet (); Adapter. Fill (DS); This.gvData.DataSource = ds; This.gvData.DataBind (); } catch {Response.Write ("Error happend!"); Response.Flush (); Response.End (); } finally {if (adapter! = NULL) {adapter. Dispose (); } if (cmd! = null) {cmd. Dispose (); } if ((conn! = null) && (conn. state = = ConnectionState.Open)) {Conn. Close (); } } } }