1

I have a GridView where the user selects a row, and then is taken to a FormView with more data from the record selected. However, the filter expression isn't working. This is my data source for the FormView:

<asp:AccessDataSource ID="adsCourse" runat="server" DataFile="~/App_Data/courseinfo.mdb"
    FilterExpression="prefix='{0}' AND course_number='{1}'" SelectCommand="SELECT * FROM [tableCourse]">
    <FilterParameters>
        <asp:ControlParameter Name="prefix" ControlID="GridView1" PropertyName="SelectedValue" />
        <asp:ControlParameter Name="course_number" ControlID="GridView1" PropertyName="SelectedValue" />
    </FilterParameters>
</asp:AccessDataSource>

As you can see, I'm trying to get both the prefix and course_number from the selected row in the GridView control. If I get just the prefix, it works, but it can't seem to get anything else. With both parameters, my FormView is just showing up blank. Any ideas?

Sara
  • 1,573
  • 5
  • 19
  • 27

1 Answers1

0

The examples I've seen of AccessDataSource always use ? for placeholders, not {0}.

<asp:AccessDataSource 
            ID="adsCourse" 
            runat="server" 
            DataFile="~/App_Data/courseinfo.mdb"
            FilterExpression="prefix = ? AND course_number = ?" 
            SelectCommand="SELECT * FROM [tableCourse]">
    <FilterParameters>
        <asp:ControlParameter Name="prefix" ControlID="GridView1" PropertyName="SelectedValue" />
        <asp:ControlParameter Name="course_number" ControlID="GridView1" PropertyName="SelectedValue" />
    </FilterParameters>
</asp:AccessDataSource>
Samuel Neff
  • 73,278
  • 17
  • 138
  • 182