protected void gvItemGroup_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow _row = (GridViewRow)((Control)e.CommandSource).NamingContainer; if (_row != null) { TextBox _GroupItemTypeIDTextBox = (TextBox)_row.FindControl("GroupItemTypeIDTextBox"); if ((_GroupItemTypeIDTextBox != null) && (!String.IsNullOrEmpty(_GroupItemTypeIDTextBox.Text))) { control.ItemGroupTbl _ItemGroup = new control.ItemGroupTbl(); Literal _ItemGroupIDLiteral = (Literal)_row.FindControl("ItemGroupIDLiteral"); _ItemGroup.ItemGroupID = (_ItemGroupIDLiteral != null) ? Convert.ToInt32(_ItemGroupIDLiteral.Text) : 0; if (e.CommandName.Equals("Delete")) { _ItemGroup.DeleteItemGroup(_ItemGroup.ItemGroupID); } else { TextBox _ItemTypeIDTextBox = (TextBox)_row.FindControl("ItemTypeIDTextBox"); CheckBox _Enabled = (CheckBox)_row.FindControl("EnabledCheckBox"); if (e.CommandName.Equals("Add") || e.CommandName.Equals("Insert")) { _ItemGroup.InsertItemGroup(_ItemGroup); } else if (e.CommandName.Equals("Update")) { _ItemGroup.UpdateItemGroup(_ItemGroup, _ItemGroup.ItemGroupID); } } } //gvItemGroup.DataBind(); } }
protected void btnAddItem_Click(object sender, EventArgs e) { // for each item that is selected remove from list foreach (GridViewRow _row in gvItemsNotInGroup.Rows) { // Access the CheckBox CheckBox _cbxAddItem = (CheckBox)_row.FindControl("cbxAddItem"); if (_cbxAddItem != null && _cbxAddItem.Checked) { DropDownList _ddlItem = (DropDownList)_row.FindControl("ddlItemTypeDesc"); TrackerDotNet.control.ItemGroupTbl _ITG = new control.ItemGroupTbl(); _ITG.GroupItemTypeID = Convert.ToInt32(ddlGroupItems.SelectedValue); _ITG.ItemTypeID = Convert.ToInt32(_ddlItem.SelectedValue); _ITG.ItemTypeSortPos = _ITG.GetLastGroupItemSortPos(_ITG.GroupItemTypeID) + 1; _ITG.Enabled = true; _ITG.Notes = "added on ItemGroup form"; _ITG.InsertItemGroup(_ITG); } } gvItemsInList.DataBind(); gvItemsNotInGroup.DataBind(); updtPnlItemsInList.Update(); }