2013-02-19 5 views
0

누구든지 나를 도울 수 있습니까? 나는 RowEditing의 기능을 작동하도록 관리해 왔고 지금은이를 수행하도록 RowUpdating을 시도하고있다. 내 gridview에 설치는 내가 MS SQL에 미리 컴파일 된 저장 프로 시저에 대한 매개 변수로 업데이트 될 예정이다 컬럼을 통과하기의 RowUpdating을 얻으려고코드를 통해 저장 프로 시저를 업데이트하는 GridView

<asp:GridView ID="CountryGridView" runat="server" AutoGenerateColumns="false" CssClass="mGrid" OnRowEditing="CountryGridView_RowEditing" OnRowCancelingEdit="CountryGridView_RowCancelingEdit" > 
        <Columns> 
         <asp:BoundField ReadOnly="true" DataField="i_SK_Accom" HeaderText="i_SK_Accom" Visible="false" /> 
         <asp:BoundField ReadOnly="true" DataField="Accom_Code" HeaderText="Accom Code" /> 
         <asp:BoundField ReadOnly="true" DataField="Accom_Name" HeaderText="Accom Name" /> 
         <asp:BoundField DataField="OP49_Required" HeaderText="OP49 Required?" /> 
         <asp:BoundField DataField="Weekly" HeaderText="Weekly" /> 
         <asp:BoundField DataField="Daily" HeaderText="Daily" /> 
         <asp:CommandField ShowEditButton="true" ButtonType="Image" EditImageUrl="~/Images/Edit.gif" UpdateImageUrl="~/Images/save.png" CancelImageUrl="~/Images/cancel.png" ControlStyle-CssClass="ImageButton" /> 
        </Columns> 
       </asp:GridView> 

다음 ASP 어입니다. 일반적인 방법은 아래와 같습니다만, 그리드 뷰를 작동 시키는데 어려움을 겪고 있습니다. 상기에 명시된

SqlCommand commEditConsultant = new SqlCommand("IFACE_JFA_ACCOM", conn.sbConn); 
    commEditConsultant.CommandType = CommandType.StoredProcedure; 

    try 
    { 
     commEditConsultant.Parameters.Add("@Statement", SqlDbType.VarChar).Value = "AccomUpdate"; 
     commEditConsultant.Parameters.Add("@Page", SqlDbType.VarChar).Value = "OP49"; 
     commEditConsultant.Parameters.Add("@PC_Username", SqlDbType.VarChar).Value = HttpContext.Current.User.Identity.Name.ToString(); 
     commEditConsultant.Parameters.Add("@Season_Name", SqlDbType.VarChar).Value = Season.Text; 
     commEditConsultant.Parameters.Add("@i_SK_Accom", SqlDbType.VarChar).Value = Request["i_SK_Accom"].Trim().ToString(); 
     commEditConsultant.Parameters.Add("@OP49_Required", SqlDbType.VarChar).Value = ddl_OP49Required.SelectedItem.Value; 
     commEditConsultant.Parameters.Add("@Weekly", SqlDbType.VarChar).Value = ddl_OP49Weekly.SelectedItem.Value; 
     commEditConsultant.Parameters.Add("@Daily", SqlDbType.VarChar).Value = ddl_OP49Daily.SelectedItem.Value; 
    } 

필드는 gridview에 대해 동일한 필요하지만 임 SqlCommand에로 통과하는 변수의 gridview에게/파라미터에 rRowEditing 값을 얻기 위해 분투. 관심의

ID 년대는 :

DataBinder - BindCountryGrid 
    DataReader - CountryGridSelectReader 

답변

0

은 결국 그것을 밖으로 근무 :

protected void CountryGridView_RowUpdating(object sender, GridViewUpdateEventArgs e) 
     { 
      Label Textbox_Accom = (Label)gv_CountryGridView.Rows[e.RowIndex].FindControl("lbl_Accom_Code"); 
      Label Textbox_Accom_Name = (Label)gv_CountryGridView.Rows[e.RowIndex].FindControl("lbl_Accom_Name"); 
      DropDownList Textbox_OP49 = (DropDownList)gv_CountryGridView.Rows[e.RowIndex].FindControl("ddl_OP49"); 
      DropDownList Textbox_Weekly = (DropDownList)gv_CountryGridView.Rows[e.RowIndex].FindControl("ddl_Weekly"); 
      DropDownList Textbox_Daily = (DropDownList)gv_CountryGridView.Rows[e.RowIndex].FindControl("ddl_Daily"); 
      TextBox Textbox_FRRStartDate = (TextBox)gv_CountryGridView.Rows[e.RowIndex].FindControl("txt_FRRStartDate"); 

      SqlCommand commEditConsultant = new SqlCommand("IFACE_JFA_ACCOM", ConnJFA); 
      commEditConsultant.CommandType = CommandType.StoredProcedure; 

      commEditConsultant.Parameters.Add("@Statement", SqlDbType.VarChar).Value = "AccomGridUpdate"; 
      commEditConsultant.Parameters.Add("@Page", SqlDbType.VarChar).Value = "OP49"; 
      commEditConsultant.Parameters.Add("@PC_Username", SqlDbType.VarChar).Value = HttpContext.Current.User.Identity.Name.ToUpper().ToString(); 
      commEditConsultant.Parameters.Add("@Season_Name", SqlDbType.VarChar).Value = txt_Season.Text; 
      commEditConsultant.Parameters.Add("@Accom_Code", SqlDbType.VarChar).Value = Textbox_Accom.Text; 
      commEditConsultant.Parameters.Add("@i_FK_SeasonID", SqlDbType.VarChar).Value = Request["i_FK_SeasonID"].Trim().ToString(); 
      commEditConsultant.Parameters.Add("@OP49_Required", SqlDbType.VarChar).Value = Textbox_OP49.Text; 
      commEditConsultant.Parameters.Add("@Weekly", SqlDbType.VarChar).Value = Textbox_Weekly.Text; 
      commEditConsultant.Parameters.Add("@Daily", SqlDbType.VarChar).Value = Textbox_Daily.Text; 
      commEditConsultant.Parameters.Add("@FRR_StartDate", SqlDbType.VarChar).Value = Textbox_FRRStartDate.Text; 

      ConnJFA.Open(); 
      commEditConsultant.ExecuteNonQuery(); 
      gv_CountryGridView.EditIndex = -1; 
      Error_Dashboard.Text = Textbox_Accom.Text + " - " + Textbox_Accom_Name.Text + " Updated Successfully!"; 
      ConnJFA.Close(); 
      BindCountryGrid(); 


     } 
:

코드 뒤에 다음 resenble 필요

관련 문제