예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Calling ProvinceList From DB
            if (!IsPostBack)
            {
                //provincelist.BackColor= System.Drawing.ColorTranslator.FromHtml(listcolor);
                //provincelist.Style.Add("border-radius", "5px");
                //provincelist.Style.Add("background-color", "rgba(142,150,175, 0.5)");

                //provincelist.Style.Add("outline", "1px dotted #333");

                //provincelist.BorderStyle= (BorderStyle)Enum.Parse(typeof(BorderStyle),
                //             provincelist.SelectedItem.Text);

                CsProvincelist ProvinceList = new CsProvincelist(ProvinceTable);

                try
                {
                    ConnectionClass.GetPVlist(ProvinceList);
                    provincelist.DataSource     = ProvinceList.Provinces;
                    provincelist.DataTextField  = ProvinceList.Provinces.Columns["provinceName"].ToString();
                    provincelist.DataValueField = ProvinceList.Provinces.Columns["provinceCode"].ToString();
                    provincelist.DataBind();
                }
                finally
                {
                }
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            AbleTextBoxes(Page);
            provincelist.SelectedItem.Text = "- Please select province - ";

            CsProvincelist ProvinceList = new CsProvincelist(ProvinceTable);

            ConnectionClass.GetPVlist(ProvinceList);



            provincelist.DataSource     = ProvinceList.Provinces;
            provincelist.DataTextField  = ProvinceList.Provinces.Columns["provinceName"].ToString();
            provincelist.DataValueField = ProvinceList.Provinces.Columns["provinceCode"].ToString();
            provincelist.DataBind();

            //provincelist.Enabled = true;
            btnUpdate.Visible = false;
            btnSave.Visible   = true;
        }
        // Get Province list into dropdownlist
        // 031 customer_addnew.aspx
        public static void GetPVlist(CsProvincelist pv)
        {
            string bQuery = string.Format(@"SELECT * FROM tblProvince ORDER BY provinceCode;");

            cmdString = new SqlCommand(bQuery, cntString);

            try
            {
                cntString.Open();
                SqlDataAdapter da = new SqlDataAdapter(cmdString);

                DataTable dt = new DataTable();
                DataSet   ds = new DataSet();
                da.Fill(dt);
                ds.Tables.Add(dt);

                pv.Provinces = ds.Tables[0];
            }

            finally
            {
                cntString.Close();
            }
        }