임시해결책 ㅜ_ㅜ

속도 처리가 늦지만 간단하게 쓰고 싶을때..

SqlDataSource 자체검색을 많이 쓴다 컨트롤이 하나이면 상관없는데.. 두개 이상의 컨트롤이 있으면

검색이 안된다(?!) (두개다 값이 있어야 한다)

그럴때 ....


 

 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
            CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="Black" GridLines="Horizontal">
            <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
            <Columns>
                <asp:BoundField DataField="idx" HeaderText="idx" SortExpression="idx" />
                <asp:BoundField DataField="board_big_type" HeaderText="board_big_type" SortExpression="board_big_type" />
                <asp:BoundField DataField="member_id" HeaderText="member_id" SortExpression="member_id" />
                <asp:BoundField DataField="read_num" HeaderText="read_num" SortExpression="read_num" />
                <asp:BoundField DataField="board_name" HeaderText="board_name" SortExpression="board_name" />
            </Columns>
            <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
            <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
        </asp:GridView>

 

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ALIMBADAConnectionString %>"
            FilterExpression="member_id='{0}'" SelectCommand="SELECT * FROM [001_BOARD]" OnFiltering="SqlDataSource1_Filtering">

 

 

//컨트롤이 한개일땐 상관없지만..

//컨트롤이 두개이면 두개가 다 입력이 되어야만 검색이된다...TextBox1에 값이 없으면 검색안됨
<FilterParameters>
     <asp:ControlParameter ControlID="TextBox1" Name="member_id" 

    PropertyName="Text" DefaultValue=" " /> <--DefaultValue에 공백 추가
     <asp:ControlParameter ControlID="DropDownList1" 

Name="newparameter"  PropertyName="SelectedValue" />
            </FilterParameters>


</asp:SqlDataSource>

 

//일단 디폴트 값이 있으면  OnFiltering="SqlDataSource1_Filtering" 이벤트를 거쳐간다

//값이 없으면 건너뜀

 

   protected void SqlDataSource1_Filtering(object sender, SqlDataSourceFilteringEventArgs e)
    {

        if (TextBox1.Text == "")
        {
            SqlDataSource1.FilterExpression = ""; //전체검색이것지요 디폴드값이 " " 이였기때문에...
        }else{


             SqlDataSource1.FilterExpression = "요기에 필요한 검색조건 처리 등등 응용하면됨";
             //SqlDataSource1.FilterExpression = "member_age ='"+this.DropDownList1.SelectedValue+"' 
              //and member_id ='"+TextBox1.Text+"';
       }
    }

+ Recent posts