i have been stuck on this problem for hours and can not seem to figure it out. I have a gridview I populated from a sql data source taht gives me this table:
I want to add a custom dropdown list that has the numbers 1,5,7 to filter this data by minimum number of animals. heres the code for the drop down.
Minimum Animals:
<asp:DropDownList ID="ddlMinimumAnimals" runat="server"
AutoPostBack = "True" AppendDataBoundItems = "True">
<asp:ListItem Text = "1" Value = "1"></asp:ListItem>
<asp:ListItem Text = "5" Value = "1"></asp:ListItem>
<asp:ListItem Text = "7" Value = "1"></asp:ListItem>
</asp:DropDownList>
I just want that when i click the dropdown it filters the table to the minimum, all the tutorials I have found do not use a stored procedure so I am not sure how to bind the data.
Gridview Code:
<asp:GridView ID="GridView2" class="grids" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" AllowSorting="True" AllowPaging="True">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Animals" HeaderText="Animals" SortExpression="animals" />
<asp:BoundField DataField="Company" HeaderText="Company" SortExpression="company" />
</Columns>
</asp:GridView>
Can't really tell if you want to add a custom dropdown list to the grid or to the form containing the grid. You can create custom fills on your data adapter but if it were me I'd dump the data to a datatable and either run a linq query against it to get my desired values based on the dropdown or I'd use a DataView and dump the data back into the original table once filtered. Good luck.