Exemplo n.º 1
0
    protected void cmdDisplay_Click(object sender, EventArgs e)
    {
        DatabaseComponent.DBUtil DB = new DatabaseComponent.DBUtil();

        gridItems.DataSource = DB.GetItems(
            Int32.Parse(lstCategories.SelectedItem.Value));
        gridItems.DataBind();
        pnlNew.Visible = true;
    }
Exemplo n.º 2
0
    protected void cmdAdd_Click(object sender, EventArgs e)
    {
        DatabaseComponent.DBUtil DB = new DatabaseComponent.DBUtil();

        try
        {
            DB.AddItem(txtTitle.Text, txtDescription.Text,
                       Decimal.Parse(txtPrice.Text),
                       Int32.Parse(lstCategories.SelectedItem.Value));

            gridItems.DataSource = DB.GetItems(
                Int32.Parse(lstCategories.SelectedItem.Value));
            gridItems.DataBind();
        }
        catch (FormatException err)
        {
            // An error occurs if the user has entered an
            // invalid price (non-numeric characters).
            // In this case, take no action.
            // Another option is to add a validator control
            // for the price text box to prevent invalid input.
        }
    }