In Asp.net SQLdatasource, I applied
filter expression and filter parameter. While filtering a data in the
dropdownlist, the Gridview should be loaded based on the filteration in the
dropdownlist. But Gridview is not loaded with data and gridview structure as
follows:
<tr>
<td>
<asp:DropDownList ID="DropDownList1"
runat="server"
AppendDataBoundItems="True"
DataSourceID="sqlDataSourceLocation"
DataTextField="FirstName"
DataValueField="ID"
AutoPostBack="True">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:GridView ID="GridView1" ShowHeader="False" AllowPaging="True"
runat="server"
DataSourceID="SqlDataSource1"
AutoGenerateColumns="False"
DataKeyNames="ID">
<Columns>
<asp:BoundField DataField="ID"
HeaderText="ID"
InsertVisible="False"
ReadOnly="True"
SortExpression="ID"
/>
<asp:BoundField DataField="FirstName"
HeaderText="FirstName"
SortExpression="FirstName"
/>
<asp:BoundField DataField="LastName" HeaderText="LastName"
SortExpression="LastName"
/>
<asp:BoundField DataField="Location"
HeaderText="Location"
SortExpression="Location" />
</Columns>
</asp:GridView>
</td>
</tr>
<tr><td> <asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TestDBConnectionString3 %>"
SelectCommand="SELECT
[ID],[FirstName],[LastName],[Location] FROM [Employees]"
FilterExpression="[FirstName]
= '{0}'">
<FilterParameters>
<asp:ControlParameter ControlID="DropDownList1"
Name="FirstName"
PropertyName="SelectedValue"
/>
</FilterParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="sqlDataSourceLocation"
runat="server"
ConnectionString="<%$
ConnectionStrings:TestDBConnectionString3 %>"
SelectCommand="SELECT
Distinct [FirstName], [ID] FROM [Employees]"></asp:SqlDataSource></td></tr>
</table>
Please help me regarding this.
Thanks a lot