温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Ajax实现拖动购物车源码
当前文件:
AjaxDropShoping/DropShoping.aspx.cs[2K,2009-6-12 11:31:36],打开代码结构图
AjaxDropShoping/DropShoping.aspx.cs[2K,2009-6-12 11:31:36],打开代码结构图
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Data.SqlClient;
//该源码下载自www.51aspx.com(51aspx.com)
public partial class DropShoping : System.Web.UI.Page,ICallbackEventHandler
{
string result;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
SqlDataAdapter sda = new SqlDataAdapter("select ProductName,ProductId,ProductPrice,ProductPicture from ProductMsg", con);
DataSet ds = new DataSet();
sda.Fill(ds, "Product");
this.GridView1.DataSource = ds.Tables["Product"];
this.GridView1.DataBind();
}
}
public string GetCallbackResult()
{
string res = null;
System.Threading.Thread.Sleep(1000);
int id = int.Parse(result);
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
//cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "select ProductName,ProductPrice,ProductDesgin,ProductPicture from ProductMsg where ProductId=@id";
cmd.Parameters.Add("@id", SqlDbType.Int);
cmd.Parameters["@id"].Value =id;
SqlDataReader sdr = cmd.ExecuteReader();
try
{
while (sdr.Read())
{
if (sdr.GetString(2).Length <= 80)
{
res += sdr.GetString(0) + "|" + sdr.GetDecimal(1).ToString() + "|" + sdr.GetString(2) + "|" + "picture/" + sdr.GetString(3).Trim();
}
else
{
string desgin =null;
desgin = sdr.GetString(2).Substring(0, 80) + "....";
res += sdr.GetString(0) + "|" + sdr.GetDecimal(1).ToString() + "|" + desgin + "|" + "picture/" + sdr.GetString(3).Trim();
}
}
sdr.Dispose();
con.Close();
return res;
}
catch (Exception e)
{
Response.Write(e.Message);
con.Close();
return "0";
}
}
public void RaiseCallbackEvent(string eventArgument)
{
result = eventArgument;
}
}


