コード例 #1
0
        public override void DataBind()
        {
            if (bound)
            {
                return;
            }
            bound = true;

            int?itemId = null;

            object obj = ControlUtils.GetBoundedDataField(this.NamingContainer, "ItemId");

            if (obj != null)
            {
                itemId = (int)obj;
            }

            if (itemId != null)
            {
                _dataSrc = new EmptyDataSrc();

                SqlCommand cmd = DBUtils.StoredProcedure("[Shopping_GetRelatedProducts]", cte.lib);
                DBUtils.AddCommandParameter(cmd, "ItemId", SqlDbType.Int, itemId.Value, ParameterDirection.Input);
                DataTable dt = DBUtils.GetDataSet(cmd, cte.lib).Tables[0];

                this.Data = dt;

                _dataSrc.RowsCount = dt.Rows.Count;
                _dataSrc.Data      = this.Data;
                _dataSrc.HasData   = _dataSrc.RowsCount > 0;
            }

            base.DataBind();
        }