如何使用标签绑定下拉列表

时间:2018-05-31 14:31:58

标签: c# asp.net label dropdown

我有两个SP,它们都做了不同的事情,但是它们是由I.d连接的...我如何绑定它们以便标签随着下拉选择而变化?

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Refreshdata(214, DateTime.Today, DateTime.Today.AddDays(1).AddMinutes(-1));
                BindDropDownList();
                LabelCount(214, DateTime.Today, DateTime.Today.AddDays(1).AddMinutes(-1));


            }
        }

        private void BindDropDownList()
        {
            BizManager mgr = new BizManager();

            DataView dv = mgr.GetItemSeriesMaster().DefaultView; //how to filter data
            dv.RowFilter = ProductQueryFilter;
            Dropdownlist1.DataSource = dv; //datasource == usp.getitemseriesmaster
            Dropdownlist1.DataTextField = "Description"; // the items to be displayed in the list items
            Dropdownlist1.DataValueField = "Id"; // the id of the items displayed
            Dropdownlist1.DataBind();

        }

        private string ProductQueryFilter
        {
            get
            {
                return ConfigurationManager.AppSettings["ProductQueryFilter"];
            } //returns itemseriesmaster 214 or 225 from web config key.
        }


        public void Refreshdata(int selectedProduct, DateTime shiftStart, DateTime shiftEnd)
        {
            BizManager biz = new BizManager();

            GridView1.DataSource = biz.GetPacktstatisticsForShift( //passing in the usp
                shiftStart
                , shiftEnd
                , selectedProduct).DefaultView; //passing in the parameters for the usp
            GridView1.DataBind();

        }

        public void Dropdownlist1_SelectedIndexChanged(object sender, EventArgs e) //this fires after a DDL selection
        {
            DateTime shiftStart = DateTime.Today; //declaring the param at today - As below
            DateTime shiftEnd = DateTime.Today.AddDays(1).AddMinutes(-1);
            int productId; //declaring product ID
            if (int.TryParse(Dropdownlist1.SelectedValue, out productId))
                Refreshdata(productId, shiftStart, shiftEnd);
        }

        public void LabelCount(int seriesMasterId, DateTime shiftStart, DateTime shiftEnd)
        {
            {

            }

所以,我真的被困在这里,我的标签放在一个表单视图中,因为我只需要一个非常规则更新的记录。我知道底部方法不是表单视图,但我希望可以在不使用表单视图的情况下进行解决。但即使经过数小时的互联网搜索,我也没有办法做到这一点。

0 个答案:

没有答案