0

GridQuery の結果を表示するページに Gridview があります。これは正常に動作します。同じページにチェックボックス コントロールがあり、チェックされている場合は、GridQuery の where 句に追加する必要があります。チェックボックスの状態をチェックして、フィルタリングの有無にかかわらずクエリを実行するにはどうすればよいですか。

aspx:

<table class="filter_component_css">
          <tr>
             <td>miap</td>
             <td><asp:TextBox CssClass="search_format" ID="miap_textbox" runat="server"></asp:TextBox></td>
          </tr>
          <tr>
             <td>purchase order</td>
             <td><asp:TextBox CssClass="search_format" ID="po_textbox" runat="server"></asp:TextBox></td>
          </tr>
          <tr>
              <td>manufacturer</td>
              <td><asp:TextBox CssClass="search_format" ID="manufacturer_textbox" runat="server"></asp:TextBox></td>
          </tr>
          <tr>
              <td>spare parts</td>
              <td><asp:CheckBox CssClass="search_format" ID="parts_checkbox" runat="server"  OnCheckedChanged="spareParts_Checked"/></td>
          </tr>
          <tr>
              <td>first fills</td>
              <td><asp:CheckBox CssClass="search_format" ID="fills_checkbox" runat="server" OnCheckedChanged="firstFills_Checked"/></td>
           </tr>
           <tr>
              <td>special tools</td>              
              <td><asp:Checkbox CssClass="search_format" ID="tools_checkbox" runat="server" OnCheckedChanged="specialTools_Checked"/></td>
          </tr>
          <tr>
              <td>tag</td>
              <td><asp:TextBox CssClass="search_format" ID="tag_textbox" runat="server"></asp:TextBox></td>
          </tr>  
          <tr>
              <td>item to be lubricated</td>
              <td><asp:TextBox CssClass="search_format" ID="item_lubricated_textbox" runat="server"></asp:TextBox></td>
          </tr>
          <tr>
              <td>include deleted</td>
              <td><asp:CheckBox CssClass="search_format" ID="include_deleted_checkbox" runat="server" OnCheckedChanged="includeDeleted_Checked"/></td>
          </tr>
          <tr>
              <td>include purchase orders manually inserted</td>
              <td><asp:CheckBox CssClass="search_format" ID="manually_inserted_checkbox" runat="server" OnCheckedChanged="manualInsert_Checked"/></td>
          </tr>
          <tr>
              <td>material code</td>
              <td><asp:TextBox CssClass="search_format" ID="material_code_textbox" runat="server"/></td>
          </tr>   
              <tr>
                <td colspan="2">
                    <asp:Button ID="buttonReset"  CssClass="filter_component_css_3" runat="server" Text="Reset" OnClick="submitResetClick"/>
                    <asp:Button ID="buttonSearch"  CssClass="filter_component_css_3" runat="server" Text="Search" OnClick="submitSearchClick"/>
              </td>
            </tr>
        </table>


<asp:SqlDataSource ID="SqlDataSource_Search" runat="server" ConnectionString="Server=kzatdev04;Database=AgipKco.CMHS;Trusted_Connection=True;" 
           selectCommand="select aktb_ItemUpload.miap as miap, 
                aktb_PurchaseOrder.pocode as pocode, 
                aktb_PurchaseOrder.materialdescription as materialdescription,
                aktb_Supplier.name as suppliername,
                aktb_Manufacturer.name as manufacturername,
                aktb_CMRFHeader.spareparts as spareparts,
                aktb_CMRFHeader.consumables as firstfills,
                aktb_CMRFHeader.specialtools as specialtools,
                aktb_PrjStrTag.tag as tag,
                aktb_ItemTobeLubricated.itemtobelubricated as itemtobelubricated,
                aktb_ProjectStructure.subsystem as subsystem,
                aktb_ProjectStructure.cu as cu,
                aktb_ProjectStructure.ffu as ffu,
                aktb_ProjectStructure.deleted as ps_deleted,
                aktb_PurchaseOrder.manuallyInserted as po_manuallyinserted,
                aktb_ItemUpload.materialCode as materialcode
                from aktb_ItemUpload>

                <FilterParameters> 
                    <asp:ControlParameter ControlID="parts_checkbox" Name="parts_checkbox" PropertyName="Checked" /> 
                    <asp:ControlParameter ControlID="fills_checkbox" Name="fills_checkbox" PropertyName="Checked" /> 
                    <asp:ControlParameter ControlID="tools_checkbox" Name="tools_checkbox" PropertyName="Checked" /> 
                    <asp:ControlParameter ControlID="include_deleted_checkbox" Name="parts_checkbox" PropertyName="Checked" /> 
                    <asp:ControlParameter ControlID="manually_inserted_checkbox" Name="manually_inserted_checkbox" PropertyName="Checked" /> 
                </FilterParameters> 

</asp:SqlDataSource>

c#:

protected void submitSearchClick(object sender, EventArgs e) 
    {
                ViewState.Add("flag", true);

                    GridViewS.DataSource = SqlDataSource_Search;

                    SqlDataSource_Search.FilterExpression = "miap like '%" + miap_textbox.Text + "%' and pocode like '%" + po_textbox.Text + "%' and materialdescription like '%" + material_desc_textbox.Text + "%' and suppliername like '%" + supplier_textbox.Text + "%' and manufacturername like '%" + manufacturer_textbox.Text
                     + "%' and tag like '%" + tag_textbox.Text + "%' and itemtobelubricated like '%" + item_lubricated_textbox.Text + "%' and subsystem like '%" + subsystem_textbox.Text
                     + "%' and cu like '%" + cu_textbox.Text + "%' and ffu like '%" + ffu_textbox.Text + "%' and materialcode like '%" + material_code_textbox.Text + "%'";

                    GridViewS.DataBind();        
    }
4

0 に答える 0