Click here to Skip to main content
15,886,815 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
i want to filter grid view from dropdownlist and text box , like i select the column from dropdown and name,id,phone number anything from text box how can i do this process
Posted
Comments
Arjun YK 2-Jul-12 3:35am    
can u please be clear with the question.
Mohammed Abdul Muqeet 2-Jul-12 3:46am    
i have a gridview i want to filter that grid view , drop down list should will select the column and text box will filter the column.
like in ID NAME Phone Designation fields in gridview . i will select Designation in dropdown and type programmer in text box .so it should filter programmers from the gridview
Sandeep Mewara 2-Jul-12 3:37am    
Not clear. Dropdown & textbox are inside grid or outside?
Mohammed Abdul Muqeet 2-Jul-12 3:43am    
dropdownlist and text box should be outside the gridview

1.If YOu are binding grid in code behind refer this
http://msdn.microsoft.com/en-us/library/system.data.dataview.rowfilter.aspx

2.If you are using SqlDatsource
XML
<asp:textbox id="contractID" runat="server" >duration</asp:textbox>
<asp:textbox id="duration" runat="server" >duration</asp:textbox>
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
</asp:GridView>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT DISTINCT * FROM [Contract]" FilterExpression="contractID LIKE '{0}%' AND duration LIKE '{1}%'">
<FilterParameters>
<asp:ControlParameter ControlID="contractID" Name="contractID"
PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="duration" Name="duration" PropertyName="Text"
Type="String" />
</FilterParameters>
</asp:SqlDataSource>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900