2013-11-22 2 views
0

사용자가 드롭 다운에서 값을 선택하고 텍스트 상자에 몇 개의 자유 텍스트를 입력 한 다음 해당 작업이 실행되는지 여부를 선택하는 확인란이 있는지 확인합니다. 이것은 내가 acf.isAchieved = chkAchieved.Enabled;체크 박스 값을 체크 박스의 그리드에 저장하는 방법은 선택되어 있습니까?

나는 임 오른쪽 코드를 누르거나하지 있는지 확인하는 값을 변경하려고 내 코드에 쓴 것입니다

. acf.isAchieved = false;acf.isAchieved = true; 모든 확인란을 선택하거나 선택하지 않고 코드를 변경하면됩니다. 제발 도와주세요

protected void BtnUpdate_Click(object sender, EventArgs e) 
     { 
      Label lbl = (Label)this.Parent.FindControl("lblCenterNo"); 
      ActionPlanPresenter actionPlan = new ActionPlanPresenter(); 

      int count; 
      if (editFalg) 
      { 

      } 

      foreach (GridViewRow grd in GridView1.Rows) 
      { 
       TextBox txtdesc = (TextBox)grd.FindControl("txtDescription"); 
       TextBox txtComments = (TextBox)grd.FindControl("txtComments"); 
       DropDownList ddlCategory = (DropDownList)grd.FindControl("ddlCategory"); 
       DropDownList ddlSubcategory = (DropDownList)grd.FindControl("ddl_subcategory"); 
       CheckBox chkAchieved = (CheckBox)grd.FindControl("CheckBoxAchievedEdit"); 
       CheckBoxList chkBoxList = (CheckBoxList)grd.FindControl("cbList"); 
       if (GridView1.Rows.Count == grd.RowIndex + 1) 
       { 
        if (editFalg) 
        { 

         Presenters.Presenters.ActionPlanPresenter _planPresenter = new Presenters.Presenters.ActionPlanPresenter(); 
         Database.Action act = new Database.Action(); 
         List<ActionChild> lstActc = new List<ActionChild>(); 
         act.idCenter = actionPlan.getCenterIdByNumber(lbl.Text.Trim()); 
         act.idCategory = Convert.ToInt32(ddlCategory.SelectedValue); 
         act.ActionDescription = txtdesc.Text; 
         act.idSubCategory = Convert.ToInt32(ddlSubcategory.SelectedValue); 
         act.Comments = txtComments.Text; 
         act.Achieved = chkAchieved.Checked; 
         act.CreatedDate = DateTime.Now; 
         act.CreatedBy = DM.Utility.ExtensionMethods.EnumExtensionMethods.GlobalCommon.CurrrentUser; 
         act.ModifiedDate = DateTime.Now; 
         act.ModifiedBy = DM.Utility.ExtensionMethods.EnumExtensionMethods.GlobalCommon.CurrrentUser; 
         act.isActive = true; 
         act.isDelete = false; 
         foreach (ListItem li in chkBoxList.Items) 
         { 
          if (li.Selected) 
          { 
           ActionChild actC = new ActionChild(); 
           actC.idCalendar = Convert.ToInt32(li.Value); 
           // actC.Comments = txtComments.Text; 
           actC.CreatedDate = DateTime.Now; 
           actC.CreatedBy = DM.Utility.ExtensionMethods.EnumExtensionMethods.GlobalCommon.CurrrentUser; 
           actC.ModifiedDate = DateTime.Now; 
           actC.ModifiedBy = DM.Utility.ExtensionMethods.EnumExtensionMethods.GlobalCommon.CurrrentUser; 
           actC.isActive = true; 
           actC.isDelete = false; 
           actC.Selected = true; 
           lstActc.Add(actC); 
          } 
         } 
         _planPresenter.InsertNewAction(act, lstActc); 
         editFalg = false; 
        } 
       }      

        else 
        { 
         Label lblID = (Label)grd.FindControl("lbl_ActionId"); 

         ActionSelfModel acf = new ActionSelfModel(); 
         acf.categoryId = Convert.ToInt32(ddlCategory.SelectedValue); 
         acf.subcategoryId = Convert.ToInt32(ddlSubcategory.SelectedValue); 
         acf.isAchieved = chkAchieved.Enabled; 

         acf.comments = txtComments.Text.Trim(); 
         acf.Description = txtdesc.Text; 

         // acf.SubCategoryName = txtSubCatName.Text; 
         acf.idAction = Convert.ToInt32(lblID.Text); 
         List<FIN_Calendar> lstCal = new List<FIN_Calendar>(); 
         foreach (ListItem li in chkBoxList.Items) 
         { 
          FIN_Calendar c = new FIN_Calendar(); 
          if (li.Selected == true) 
          { 
           c.idCalendar = Convert.ToInt32(li.Value); 
           c.Period = li.Text; 
           lstCal.Add(c); 
           //acf.Cals.Add(c); 
           // acf.Cals.Add(c); 

          } 
         } 
         acf.Cals = lstCal; 
         _actionPlan.updateAction(acf); 
        }    

      } 

     } 
+0

winforms입니까? 또는 wpf? –

+0

사용함? 왜 체크하지 않았습니까? – Steve

답변

0

datagridview는 데이터를 나타냅니다. datagridview는 아무 것도 저장하지 않습니다. datagridviews and their data sources에 대해 읽으십시오. 그런 다음 문제가있는 경우 여기에서 다시 언급하고 다시 방문하십시오.

+0

이것은 그리드 뷰이지만 실제로는 컨트롤입니다. – user3023103

+0

내 눈금이 잘 동작합니다. 나는이 문제를 제외하고는 아무런 문제가 없다. – user3023103

+0

네,하지만 저장하고 싶었죠? –

관련 문제