Click here to Skip to main content
15,905,971 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<h3 align="center">
               City :
               <asp:DropDownList ID="ddlCity" runat="server">
               </asp:DropDownList>
           </h3>
<asp:LinqDataSource
    ContextTypeName="ExampleDataContext"
    TableName="Products"
    Where="Price>@UserPrice"
    ID="LinqDataSource1"
    runat="server">

</asp:LinqDataSource>
<asp:GridView
    DataSourceID="LinqDataSource1"
    ID="GridView1"
    runat="server">
 <Columns>
<asp:BoundField DataField="city" HeaderText="City" SortExpression="city" ReadOnly="true" />
&lt;/Columns&gt;
</asp:GridView>

Posted
Comments
Vineet_2109 28-Apr-11 7:06am    
If i select cityname from dropdown it should show all data in grid with that particular selected city....

1)Set autopostback for dropdownlist to true.
XML
<asp:DropDownList ID="ddlCity" runat="server" autopostback="True"> 
              </asp:DropDownList>

2)In dropdown list selectedindexchanged event set the where property of LinkDatasource1.
Look at nit_singh answer.
 
Share this answer
 
Did you tried like this
LinqDataSource1.Where = ddlCity.SelectedItem.value;
LinqDataSource1.WhereParameters.Add("name1", "value1");
 
Share this answer
 
Comments
Vineet_2109 28-Apr-11 7:13am    
LinqDataSource1.WhereParameters.Add("name1", "value1");

What this "name1" and "value1" contains .. ??? can you specify .. ?
m@dhu 28-Apr-11 7:20am    
name is the parmeter and value is the value for that parameter.
Vineet_2109 28-Apr-11 7:22am    
its like i want by city ..in database there is column name city so what would be parameter and value .. ???
nit_singh 28-Apr-11 7:25am    
then it iwll became like LinqDataSource1.WhereParameters.Add("city", "cityValue");

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