views:

439

answers:

1

Hello all,

I am using c#.net.

I have a search form (within a View), when the user provides the correct details for each textbox and presses the search button, it redirects to another View within the same WebForm.

I am using LINQ and ObjectDataSource to pull back the results for the database. As the query requires parameters (used within the where clause) I need to provide SelectParameters. I thought FormParameter was the correct type to use however it requires a Default Value which is fine although even when I provide details within the textboxes, it uses the Default Value and I don’t understand why.

<asp:FormParameter Name="personName" FormField="searchName" DefaultValue="random" />
<asp:FormParameter Name="dateFrom" FormField="searchFromDate" DefaultValue="01/08/2009" />
<asp:FormParameter Name="dateTo" FormField="searchToDate" DefaultValue="01/10/2009" />

Thanks in advance for any help.

Clare

A: 

I realised I was using the wrong type. I should have instead used ControlParameter:

        <SelectParameters>
          <asp:ControlParameter Name="personName" ControlID="searchName" />
          <asp:ControlParameter Name="dateFrom" ControlID="searchFromDate" />
          <asp:ControlParameter Name="dateTo" ControlID="searchToDate" />
        </SelectParameters>
ClareBear