Home All Groups Group Topic Archive Search About
Author
6 Jul 2006 7:21 PM
rgelfand2
My goal is to apply data entered in multiple text boxes as parameters
for sqldatasource filter bound to a datagrid control

I have created an asp .net web page.   To the page I added datagrid
control.   The datagrid control getting it's data from sqldatasource.
The sqldatasource is defined as a straight select against one table.


I have, also, added textbox control to the same page.  I have defined
filter parameter for the sqldatasource as textbox1.text.  The filter
expression is yow_model_no like  '%{0}%' .
This works.


If I try to add another text box and define another filter parameter.
In the filter expression I specify yow_model_no like  '%{0}%'  and
upc_code like '%{1}%'.
This doesn't work.


Could someone tell me where I went wrong here?


Thanks in advance

Author
6 Jul 2006 10:37 PM
CaffieneRush@gmail.com
Works for me.
Selects all rows within Northwind.Customer table such that CustomerID
and ContactName columns contains at least an 'i' in it.

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
FilterExpression="CustomerID LIKE '%{0}%' AND ContactName LIKE '%{1}%'"
SelectCommand="SELECT * FROM [Customers]">
    <FilterParameters>
        <asp:Parameter DefaultValue="i" Name="p1" />
        <asp:Parameter DefaultValue="i" Name="p2" />
    </FilterParameters>
</asp:SqlDataSource>

rgelfa***@hotmail.com wrote:
Show quoteHide quote
> My goal is to apply data entered in multiple text boxes as parameters
> for sqldatasource filter bound to a datagrid control
>
> I have created an asp .net web page.   To the page I added datagrid
> control.   The datagrid control getting it's data from sqldatasource.
> The sqldatasource is defined as a straight select against one table.
>
>
> I have, also, added textbox control to the same page.  I have defined
> filter parameter for the sqldatasource as textbox1.text.  The filter
> expression is yow_model_no like  '%{0}%' .
> This works.
>
>
> If I try to add another text box and define another filter parameter.
> In the filter expression I specify yow_model_no like  '%{0}%'  and
> upc_code like '%{1}%'.
> This doesn't work.
>
>
> Could someone tell me where I went wrong here?
>
>
> Thanks in advance