首頁  >  文章  >  web前端  >  Jquery+ajax请求data显示在GridView上(asp.net)_jquery

Jquery+ajax请求data显示在GridView上(asp.net)_jquery

WBOY
WBOY原創
2016-05-16 18:20:391125瀏覽

AJAXLoadProgressForm.aspx:

复制代码 代码如下:













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();
}
}
}
}
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn