Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IUBAT13wfa.DAL.City ct = new IUBAT13wfa.DAL.City();
            GridView1.DataSource = ct.Select().Tables[0];

            GridView1.DataBind();
        }
Пример #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            lblEName.Text    = "";
            lblECountry.Text = "";
            lblMessage.Text  = "";

            int er = 0;

            if (txtName.Text == "")
            {
                er++;
                lblEName.Text = "Required";
            }

            if (ddlCountry.SelectedIndex == 0)
            {
                er++;
                lblECountry.Text = "Required";
            }
            if (er > 0)
            {
                return;
            }


            IUBAT13wfa.DAL.City ct = new IUBAT13wfa.DAL.City();
            ct.Name      = txtName.Text;
            ct.CountryId = Convert.ToInt32(ddlCountry.SelectedValue);

            if (ct.Insert())
            {
                lblMessage.ForeColor     = System.Drawing.Color.Green;
                lblMessage.Text          = "City Inserted";
                txtName.Text             = "";
                ddlCountry.SelectedIndex = 0;
                txtName.Focus();
            }
            else
            {
                lblMessage.Text      = ct.Error;
                lblMessage.ForeColor = System.Drawing.Color.Red;
            }
        }