userControl/Product.ascx.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace MyPetShop.userControl
{
public partial class Product1 : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DB db = new DB();
SqlConnection con = db.GetCon();//连接数据库
con.Open();//打开连接
SqlCommand cmd = new SqlCommand("select Top 10 * from Category",con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds=new DataSet();
sda.Fill(ds);
dlClass.DataKeyField = ds.Tables[0].Columns[0].ToString();
dlClass.DataSource = ds.Tables[0].DefaultView;
dlClass.DataBind();
}
}
protected void dlClass_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "select")
{
Response.Redirect("~/ProcShow.aspx?CategoryId="+ e.CommandArgument.ToString());
}
}
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
