Exemplo n.º 1
0
        protected void gvCities_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditCity")
            {
                int       cityID    = Convert.ToInt32(e.CommandArgument);
                DataTable cityTable = AdminDb.GetCityByID(cityID);
                DataRow   row       = cityTable.Rows[0];
                lbCityID.Text       = cityID.ToString();
                lbCityName.Text     = row["CityName"].ToString();
                lbStateID.Text      = row["StateID"].ToString();
                lbStateName.Text    = row["StateName"].ToString();
                cbMajorCity.Checked = Convert.ToBoolean(row["MajorCity"]);

                //make modal visible and backdrop
                pnlCityEdit.Visible = true;
                pnlBackdrop.Visible = true;
            }
            else if (e.CommandName == "DeleteCity")
            {
                int cityID = Convert.ToInt32(e.CommandArgument);
                AdminDb.DeleteListing(cityID);
                BindDataToGridView();
            }
        }
Exemplo n.º 2
0
        protected void gvListings_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditListing")
            {
                int       listingID    = Convert.ToInt32(e.CommandArgument);
                DataTable listingTable = AdminDb.GetListingByID(listingID);
                DataRow   row          = listingTable.Rows[0];
                lbListingId.Text   = listingID.ToString();
                tbHeadline.Text    = row["Headline"].ToString();
                tbLocation.Text    = row["Location"].ToString();
                lbUserID.Text      = row["UserID"].ToString();
                tbPrice.Text       = row["Price"].ToString();
                tbDescription.Text = row["Description"].ToString();
                cbIsActive.Checked = Convert.ToBoolean(row["IsActive"]);

                //Bind the categories dd
                ddCategory.DataSource     = AdminDb.GetCategories();
                ddCategory.DataTextField  = "CategoryName";
                ddCategory.DataValueField = "CategoryID";
                ddCategory.DataBind();

                ddCategory.SelectedValue = row["CategoryID"].ToString();

                int catID = Convert.ToInt32(row["CategoryID"].ToString());

                //Bind the state dropdown list
                ddState.DataSource     = AdminDb.GetStates();
                ddState.DataTextField  = "Statename";
                ddState.DataValueField = "StateID";
                ddState.DataBind();

                int stateId = Convert.ToInt32(row["StateID"]);

                ddState.SelectedValue = row["StateID"].ToString();

                //Bind the edit city drop down list
                ddCity.DataSource     = AdminDb.GetCitiesByState(stateId);
                ddCity.DataTextField  = "CityName";
                ddCity.DataValueField = "CityID";
                ddCity.DataBind();

                ddCity.SelectedValue = row["CityID"].ToString();

                //Bind the edit subcategory drop down list
                ddSubCategory.DataSource     = AdminDb.GetSubcategoriesByCategory(catID);
                ddSubCategory.DataTextField  = "SubCategoryName";
                ddSubCategory.DataValueField = "SubCategoryID";
                ddSubCategory.DataBind();

                ddSubCategory.SelectedValue = row["SubCategoryID"].ToString();

                //make modal visible and backdrop
                pnlListingEdit.Visible = true;
                pnlBackdrop.Visible    = true;
            }
            else if (e.CommandName == "DeleteListing")
            {
                int listingID = Convert.ToInt32(e.CommandArgument);
                AdminDb.DeleteListing(listingID);
                BindDataToGridView();
            }
        }