Dipa Ahuja

Dipa Ahuja

  • NA
  • 3.1k
  • 713.3k

how to filter the grid view..

Oct 26 2009 1:48 PM
hello i have gridview which is showing the data from the product table

the prodct table contains tha diffrent prodct with diff names..

for example tv --- which has tv codes prefix "tv" like tv1,tv2....& so on...
ipods has the prefix "ip"... ip1,ip2 ... & so on

this is my sqldatasource..:


 

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

SelectCommand="SELECT * FROM [product]"

DeleteCommand="DELETE FROM [product] WHERE [pcode] = @pcode"

InsertCommand="Insert into [product] ([pcode], [pname], [purl], [price],[disc]) VALUES (@pcode, @pname, @purl, @price, @disc)"

UpdateCommand="UPDATE [products] SET [pname] = @pname, [disc] = @disc, [price] = @price, [purl] = @purl WHERE [pcode] = @pcode">

<DeleteParameters>

<asp:Parameter Name="pcode" Type="string" />

</DeleteParameters>

<UpdateParameters>

<asp:Parameter Name="pname" Type="string" />

<asp:Parameter Name="disc" Type="String" />

<asp:Parameter Name="price" Type="double" />

<asp:Parameter Name="purl" Type="string" />

<asp:Parameter Name="pcode" Type="string" />

</UpdateParameters>

<InsertParameters>

<asp:Parameter Name="pcode" Type="string"/>

<asp:Parameter Name="pname" Type="string" />

<asp:Parameter Name="purl" Type="string" />

<asp:Parameter Name="price" Type="double" />

<asp:Parameter Name="disc" Type="string" />

</InsertParameters>

</asp:SqlDataSource>


in select query it will select all data from product ..

is there any way to filter the gridview at the runtime that means it change the  select query of the sqlcommand (with where condition) ??

by taking the dropdown(which can contain values like "tv" which display only tv, ipods which dispay only ipods ... all will dispay all the products) or any other control??

Thanx!!



Answers (2)