コード例 #1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     int r=0;
     objCategory = new Category();
     DataTable dt = objCategory.AvailableCategoryGroup(txtcategory.Text.ToString().Trim());
     if (dt.Rows.Count == 0 && txtcategory.Text.ToString().Trim() != "")
         r = objCategory.CategoryGroupUpdate(0, txtcategory.Text.ToString().Trim());
     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");

            // string variable to store the connection string
            // retrieved from the connectionStrings section of web.config
            objCategory = new Category();
            int r = objCategory.CategoryGroupUpdate(Convert.ToInt32(txtId.Text.ToString().Trim()), txtCName.Text.ToString().Trim());
            // reset the DataList mode back to its initial state
            DataList1.EditItemIndex = -1;
            LoadCategory();
        }