Exemple #1
0
        protected void gvGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            GoodsGroup group = new GoodsGroup();

            group.GroupCode = (int)gvGroup.SelectedValue;
            GoodsTable gt = new GoodsTable();

            dlRecommend.DataSource = gt.GetRecommendGoods(group);
            dlRecommend.DataBind();
        }
Exemple #2
0
        public DataTable GetRecommendGoods(GoodsGroup group)
        {
            DataTable dt   = null;
            string    cstr = ConfigurationManager.ConnectionStrings["Db"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(cstr))
            {
                string sql = "select * from Goods where Recommend = 1 and GroupCode = @group";

                SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);

                adapter.SelectCommand.Parameters.Add("@group", SqlDbType.Int);
                adapter.SelectCommand.Parameters["@group"].Value = group.GroupCode;

                DataSet ds = new DataSet();
                adapter.Fill(ds, "RecommendGoods");
                dt = ds.Tables["RecommendGoods"];
            }
            return(dt);
        }