예제 #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int r = 0;
            ServeAtDoorstepData.CategoryDetails objCategory = new CategoryDetails();
            objCategory.CategoryID = 0;
            objCategory.CategoryName = txtcategory.Text.ToString().Trim();
            objCategory.CategoryDescription =txtcategoryDesc.Text.Trim();
            objService = new ServeAtDoorstepService();

            DataTable dt = objService.AvailableCategory(txtcategory.Text.ToString().Trim());
            if (dt.Rows.Count == 0 && txtcategory.Text.ToString().Trim() != "")
                r = objService.AddCategory(objCategory);
            txtcategory.Text = "";
            LoadCategory();
        }
예제 #2
0
        protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
        {
            // Get the DataKey value associated with current Item Index.
            int catId = (int)DataList1.DataKeys[(int)e.Item.ItemIndex];
            // Get updated value entered by user in textbox control for
            // Name field.
            TextBox txtId;
            txtId = (TextBox)e.Item.FindControl("txtId");
            TextBox txtCName;
            txtCName = (TextBox)e.Item.FindControl("txtCName");
            TextBox txtCDesc;
            txtCDesc = (TextBox)e.Item.FindControl("txtCDesc");

            // string variable to store the connection string
            // retrieved from the connectionStrings section of web.config
            ServeAtDoorstepData.CategoryDetails objCategory = new CategoryDetails();
            objCategory.CategoryID=Convert.ToInt32(txtId.Text.ToString().Trim());
            objCategory.CategoryName=txtCName.Text.ToString().Trim();
            objCategory.CategoryDescription = txtCDesc.Text.Trim();
            objService = new ServeAtDoorstepService();

            int r = objService.AddCategory(objCategory);

            // reset the DataList mode back to its initial state
            DataList1.EditItemIndex = -1;
            LoadCategory();
        }