2011-09-27 7 views
0

gridview가있는 webform이 있습니다. 각 행 옆에는 UPDATE (업데이트) 버튼이 있습니다. 그러나 내가 버튼을 누르고 필드를 편집하고 UPDATE를 누르면. 아무것도 바뀌지 않습니다. 여기Gridview가 업데이트되지 않습니다.

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
    AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
    DataKeyNames="lom_number" DataSourceID="SqlDataSource1" ForeColor="#333333" 
    GridLines="None" onselectedindexchanged="GridView1_SelectedIndexChanged"> 
    <RowStyle BackColor="#FFFBD6" ForeColor="#333333" /> 
    <Columns> 
     <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
      ShowSelectButton="True" /> 

     <asp:BoundField DataField="occurrence_date" HeaderText="occurrence_date" 
      SortExpression="occurrence_date" /> 
     <asp:BoundField DataField="report_date" HeaderText="report_date" 
      SortExpression="report_date" /> 
     <asp:BoundField DataField="report_by" HeaderText="report_by" 
      SortExpression="report_by" /> 
     <asp:BoundField DataField="identified_by" HeaderText="identified_by" 
      SortExpression="identified_by" /> 
     <asp:BoundField DataField="section_c_issue_error_identified_by" 
      HeaderText="section_c_issue_error_identified_by" 
      SortExpression="section_c_issue_error_identified_by" /> 
     <asp:BoundField DataField="section_c_comments" HeaderText="section_c_comments" 
      SortExpression="section_c_comments" /> 
     <asp:BoundField DataField="section_d_investigation" 
      HeaderText="section_d_investigation" SortExpression="section_d_investigation" /> 
     <asp:BoundField DataField="section_e_corrective_action" 
      HeaderText="section_e_corrective_action" 
      SortExpression="section_e_corrective_action" /> 
     <asp:BoundField DataField="section_f_comments" HeaderText="section_f_comments" 
      SortExpression="section_f_comments" /> 
     <asp:BoundField DataField="pre_practice_code" HeaderText="pre_practice_code" 
      SortExpression="pre_practice_code" /> 
     <asp:BoundField DataField="pre_contact" HeaderText="pre_contact" 
      SortExpression="pre_contact" /> 
     <asp:BoundField DataField="lom_number" HeaderText="lom_number" 
      InsertVisible="False" ReadOnly="True" SortExpression="lom_number" /> 
     <asp:BoundField DataField="windows_user" HeaderText="windows_user" 
      SortExpression="windows_user" /> 
     <asp:BoundField DataField="computer_name" HeaderText="computer_name" 
      SortExpression="computer_name" /> 
     <asp:BoundField DataField="time_stamp" HeaderText="time_stamp" 
      SortExpression="time_stamp" /> 

    </Columns> 
    <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /> 
    <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" /> 
    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" /> 
    <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /> 
    <AlternatingRowStyle BackColor="White" /> 
</asp:GridView> 
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:LOM %>" 
    SelectCommand="SELECT * FROM [Main_LOM_Form]" 
    ConflictDetection="CompareAllValues" 
    DeleteCommand="DELETE FROM [Main_LOM_Form] WHERE [lom_number] = @original_lom_number AND (([occurrence_date] = @original_occurrence_date) OR ([occurrence_date] IS NULL AND @original_occurrence_date IS NULL)) AND (([report_date] = @original_report_date) OR ([report_date] IS NULL AND @original_report_date IS NULL)) AND (([report_by] = @original_report_by) OR ([report_by] IS NULL AND @original_report_by IS NULL)) AND (([identified_by] = @original_identified_by) OR ([identified_by] IS NULL AND @original_identified_by IS NULL)) AND (([section_c_issue_error_identified_by] = @original_section_c_issue_error_identified_by) OR ([section_c_issue_error_identified_by] IS NULL AND @original_section_c_issue_error_identified_by IS NULL)) AND (([section_c_comments] = @original_section_c_comments) OR ([section_c_comments] IS NULL AND @original_section_c_comments IS NULL)) AND (([section_d_investigation] = @original_section_d_investigation) OR ([section_d_investigation] IS NULL AND @original_section_d_investigation IS NULL)) AND (([section_e_corrective_action] = @original_section_e_corrective_action) OR ([section_e_corrective_action] IS NULL AND @original_section_e_corrective_action IS NULL)) AND (([section_f_comments] = @original_section_f_comments) OR ([section_f_comments] IS NULL AND @original_section_f_comments IS NULL)) AND (([pre_practice_code] = @original_pre_practice_code) OR ([pre_practice_code] IS NULL AND @original_pre_practice_code IS NULL)) AND (([pre_contact] = @original_pre_contact) OR ([pre_contact] IS NULL AND @original_pre_contact IS NULL)) AND [windows_user] = @original_windows_user AND [computer_name] = @original_computer_name AND [time_stamp] = @original_time_stamp" 
    InsertCommand="INSERT INTO [Main_LOM_Form] ([occurrence_date], [report_date], [report_by], [identified_by], [section_c_issue_error_identified_by], [section_c_comments], [section_d_investigation], [section_e_corrective_action], [section_f_comments], [pre_practice_code], [pre_contact], [windows_user], [computer_name], [time_stamp]) VALUES (@occurrence_date, @report_date, @report_by, @identified_by, @section_c_issue_error_identified_by, @section_c_comments, @section_d_investigation, @section_e_corrective_action, @section_f_comments, @pre_practice_code, @pre_contact, @windows_user, @computer_name, @time_stamp)" 
    OldValuesParameterFormatString="original_{0}" 
    UpdateCommand="UPDATE [Main_LOM_Form] SET [occurrence_date] = @occurrence_date, [report_date] = @report_date, [report_by] = @report_by, [identified_by] = @identified_by, [section_c_issue_error_identified_by] = @section_c_issue_error_identified_by, [section_c_comments] = @section_c_comments, [section_d_investigation] = @section_d_investigation, [section_e_corrective_action] = @section_e_corrective_action, [section_f_comments] = @section_f_comments, [pre_practice_code] = @pre_practice_code, [pre_contact] = @pre_contact, [windows_user] = @windows_user, [computer_name] = @computer_name, [time_stamp] = @time_stamp WHERE [lom_number] = @original_lom_number AND (([occurrence_date] = @original_occurrence_date) OR ([occurrence_date] IS NULL AND @original_occurrence_date IS NULL)) AND (([report_date] = @original_report_date) OR ([report_date] IS NULL AND @original_report_date IS NULL)) AND (([report_by] = @original_report_by) OR ([report_by] IS NULL AND @original_report_by IS NULL)) AND (([identified_by] = @original_identified_by) OR ([identified_by] IS NULL AND @original_identified_by IS NULL)) AND (([section_c_issue_error_identified_by] = @original_section_c_issue_error_identified_by) OR ([section_c_issue_error_identified_by] IS NULL AND @original_section_c_issue_error_identified_by IS NULL)) AND (([section_c_comments] = @original_section_c_comments) OR ([section_c_comments] IS NULL AND @original_section_c_comments IS NULL)) AND (([section_d_investigation] = @original_section_d_investigation) OR ([section_d_investigation] IS NULL AND @original_section_d_investigation IS NULL)) AND (([section_e_corrective_action] = @original_section_e_corrective_action) OR ([section_e_corrective_action] IS NULL AND @original_section_e_corrective_action IS NULL)) AND (([section_f_comments] = @original_section_f_comments) OR ([section_f_comments] IS NULL AND @original_section_f_comments IS NULL)) AND (([pre_practice_code] = @original_pre_practice_code) OR ([pre_practice_code] IS NULL AND @original_pre_practice_code IS NULL)) AND (([pre_contact] = @original_pre_contact) OR ([pre_contact] IS NULL AND @original_pre_contact IS NULL)) AND [windows_user] = @original_windows_user AND [computer_name] = @original_computer_name AND [time_stamp] = @original_time_stamp"> 
    <DeleteParameters> 
     <asp:Parameter Name="original_lom_number" Type="Int32" /> 
     <asp:Parameter DbType="Date" Name="original_occurrence_date" /> 
     <asp:Parameter DbType="Date" Name="original_report_date" /> 
     <asp:Parameter Name="original_report_by" Type="String" /> 
     <asp:Parameter Name="original_identified_by" Type="String" /> 
     <asp:Parameter Name="original_section_c_issue_error_identified_by" 
      Type="String" /> 
     <asp:Parameter Name="original_section_c_comments" Type="String" /> 
     <asp:Parameter Name="original_section_d_investigation" Type="String" /> 
     <asp:Parameter Name="original_section_e_corrective_action" Type="String" /> 
     <asp:Parameter Name="original_section_f_comments" Type="String" /> 
     <asp:Parameter Name="original_pre_practice_code" Type="String" /> 
     <asp:Parameter Name="original_pre_contact" Type="String" /> 
     <asp:Parameter Name="original_windows_user" Type="String" /> 
     <asp:Parameter Name="original_computer_name" Type="String" /> 
     <asp:Parameter Name="original_time_stamp" Type="DateTime" /> 
    </DeleteParameters> 
    <UpdateParameters> 
     <asp:Parameter DbType="Date" Name="occurrence_date" /> 
     <asp:Parameter DbType="Date" Name="report_date" /> 
     <asp:Parameter Name="report_by" Type="String" /> 
     <asp:Parameter Name="identified_by" Type="String" /> 
     <asp:Parameter Name="section_c_issue_error_identified_by" Type="String" /> 
     <asp:Parameter Name="section_c_comments" Type="String" /> 
     <asp:Parameter Name="section_d_investigation" Type="String" /> 
     <asp:Parameter Name="section_e_corrective_action" Type="String" /> 
     <asp:Parameter Name="section_f_comments" Type="String" /> 
     <asp:Parameter Name="pre_practice_code" Type="String" /> 
     <asp:Parameter Name="pre_contact" Type="String" /> 
     <asp:Parameter Name="windows_user" Type="String" /> 
     <asp:Parameter Name="computer_name" Type="String" /> 
     <asp:Parameter Name="time_stamp" Type="DateTime" /> 
     <asp:Parameter Name="original_lom_number" Type="Int32" /> 
     <asp:Parameter DbType="Date" Name="original_occurrence_date" /> 
     <asp:Parameter DbType="Date" Name="original_report_date" /> 
     <asp:Parameter Name="original_report_by" Type="String" /> 
     <asp:Parameter Name="original_identified_by" Type="String" /> 
     <asp:Parameter Name="original_section_c_issue_error_identified_by" 
      Type="String" /> 
     <asp:Parameter Name="original_section_c_comments" Type="String" /> 
     <asp:Parameter Name="original_section_d_investigation" Type="String" /> 
     <asp:Parameter Name="original_section_e_corrective_action" Type="String" /> 
     <asp:Parameter Name="original_section_f_comments" Type="String" /> 
     <asp:Parameter Name="original_pre_practice_code" Type="String" /> 
     <asp:Parameter Name="original_pre_contact" Type="String" /> 
     <asp:Parameter Name="original_windows_user" Type="String" /> 
     <asp:Parameter Name="original_computer_name" Type="String" /> 
     <asp:Parameter Name="original_time_stamp" Type="DateTime" /> 
    </UpdateParameters> 
    <InsertParameters> 
     <asp:Parameter DbType="Date" Name="occurrence_date" /> 
     <asp:Parameter DbType="Date" Name="report_date" /> 
     <asp:Parameter Name="report_by" Type="String" /> 
     <asp:Parameter Name="identified_by" Type="String" /> 
     <asp:Parameter Name="section_c_issue_error_identified_by" Type="String" /> 
     <asp:Parameter Name="section_c_comments" Type="String" /> 
     <asp:Parameter Name="section_d_investigation" Type="String" /> 
     <asp:Parameter Name="section_e_corrective_action" Type="String" /> 
     <asp:Parameter Name="section_f_comments" Type="String" /> 
     <asp:Parameter Name="pre_practice_code" Type="String" /> 
     <asp:Parameter Name="pre_contact" Type="String" /> 
     <asp:Parameter Name="windows_user" Type="String" /> 
     <asp:Parameter Name="computer_name" Type="String" /> 
     <asp:Parameter Name="time_stamp" Type="DateTime" /> 
    </InsertParameters> 
</asp:SqlDataSource> 

그것은 내가 제임스의 도움으로 차단 쿼리됩니다 :

updateQuery "UPDATE [Main_LOM_Form] SET [occurrence_date] = @occurrence_date, [report_date] = @report_date, [report_by] = @report_by, [identified_by] = @identified_by, [section_c_issue_error_identified_by] = @section_c_issue_error_identified_by, [section_c_comments] = @section_c_comments, [section_d_investigation] = @section_d_investigation, [section_e_corrective_action] = @section_e_corrective_action, [section_f_comments] = @section_f_comments, [pre_practice_code] = @pre_practice_code, [pre_contact] = @pre_contact, [windows_user] = @windows_user, [computer_name] = @computer_name, [time_stamp] = @time_stamp WHERE [lom_number] = @original_lom_number AND (([occurrence_date] = @original_occurrence_date) OR ([occurrence_date] IS NULL AND @original_occurrence_date IS NULL)) AND (([report_date] = @original_report_date) OR ([report_date] IS NULL AND @original_report_date IS NULL)) AND (([report_by] = @original_report_by) OR ([report_by] IS NULL AND @original_report_by IS NULL)) AND (([identified_by] = @original_identified_by) OR ([identified_by] IS NULL AND @original_identified_by IS NULL)) AND (([section_c_issue_error_identified_by] = @original_section_c_issue_error_identified_by) OR ([section_c_issue_error_identified_by] IS NULL AND @original_section_c_issue_error_identified_by IS NULL)) AND (([section_c_comments] = @original_section_c_comments) OR ([section_c_comments] IS NULL AND @original_section_c_comments IS NULL)) AND (([section_d_investigation] = @original_section_d_investigation) OR ([section_d_investigation] IS NULL AND @original_section_d_investigation IS NULL)) AND (([section_e_corrective_action] = @original_section_e_corrective_action) OR ([section_e_corrective_action] IS NULL AND @original_section_e_corrective_action IS NULL)) AND (([section_f_comments] = @original_section_f_comments) OR ([section_f_comments] IS NULL AND @original_section_f_comments IS NULL)) AND (([pre_practice_code] = @original_pre_practice_code) OR ([pre_practice_code] IS NULL AND @original_pre_practice_code IS NULL)) AND (([pre_contact] = @original_pre_contact) OR ([pre_contact] IS NULL AND @original_pre_contact IS NULL)) AND [windows_user] = @original_windows_user AND [computer_name] = @original_computer_name AND [time_stamp] = @original_time_stamp" string 

내가 뭘 잘못 여기 코드는?

+0

당신은뿐만 아니라 그리드 뷰 표시를 포함 할 수 있습니다. –

답변

2

OnUpdating 이벤트 처리기를 추가하면 쿼리가 실행되기 전에 CommandText을 볼 수 있습니다. 그러면 쿼리에 문제가 있는지 파악하는 데 도움이됩니다. 마크 업에서

:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" OnUpdating="SqlDataSource1_Updating" ... > 

코드 숨김에서 :

protected void SqlDataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e) 
{  
    string updateQuery = e.Command.CommandText; 

    //inspect the update query 
} 
+0

이 하나 : GridView1_RowUpdating? –

+0

커맨드 텍스트를 어떻게 봅니까? –

+0

아니요,'SqlDataSource' 컨트롤의'OnUpdating' 이벤트를 사용하십시오. 이벤트 인수는 실행될'SqlCommand' 객체에 대한 참조를 포함합니다. –

관련 문제