Ajaxloadprogressform. aspx:
CopyCode The Code is as follows: <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" cmd.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: Copy code The Code is as follows: 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 comment STR = "select * From DBO. MERs ";
If (request ["ID"]. tostring ()! = String. Empty)
{
Repeated STR + = "where customerid = '" + request ["ID"]. tostring () + "'";
}
Cmd. commandtext = comment STR;
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 ();
}
}
}
}