Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have 3 dropdownlists in one grid view , my aim is
-> by selecting one item in 1st dropdownlist control ,
I should get related items in 2nd dropdownlist ,and when selecting one item from the 2nd dropdown I must get the related things in 3rd dropdown List.
(for ex: i select movies in 1st ddl, then i must get comedy,action....etc
when i select the comedy from 2nd ddl i must get the list of Comedy movies in 3rd ddl)
all these controls are there in grid view.


Please help me in this regard.

Thanks in Advance.
Posted
Updated 6-Jun-11 22:57pm
v2

it's very easy

<templatefiled>
<asp:dropdownlist id="ddl1" runat="server" autopostback="true" onselectedindexchanged="ddl1_onselectedindexchanged">
......

in code behind
protected void ddl1_onselectedindexchanged(object sender,EvetArgs e)
{
// ddl2 code here.
}

same as above code you can fill no of dropdown and these are all in the gridview .
i hope it should helps you.if you have any doubt ask me,
 
Share this answer
 
do you mean. "filtering"

if i'm correct, you should use the a datasource that are connected or relation to the gridview.

for example:

in dropdown1:
filter the first column

in dropdown2:
filter the second column

in dropdown3:
filter the third column.

try this link:
data set class


hope it helps.
goodluck. :)


-chaosgray-
 
Share this answer
 
Comments
LakshmiNarayana Nalluri 8-Jun-11 3:01am    
no filtering in this requirement. what i am saying is when you select ddl1 value based on that ddl2 values are selected and ddl2 -> ddl3 ....
Use Datasource for the dropdownlist 2 and 3 to the selected value using the datasource wizard.
 
Share this answer
 
You can do that by binding the data sources for the dropdownlist 2 and 3 to the selected Value of the preceding Dropdownlist.
What kind of data source do you use?
You need a data source for each dropdownlist. In VS 2010 (and I think in 08 as well) you can use the data source wizard to configure the parameters for your select method.

For an objectDataSource the markup could look something like this:

XML
<asp:ObjectDataSource ID="GenreSource" runat="server" SelectMethod="GetGenreByType"
  TypeName="GenreDao">
  <SelectParameters>
    <asp:ControlParameter ControlID="DropDown1" 
      Name="TypeID" PropertyName="SelectedValue" Type="Object" />
  </SelectParameters> 
</asp:ObjectDataSource>

Event though this might look like actual markup, this is mere pseudocode which is not tested.

The ControlParameter is the key, you can use this method with other DataSources as well.
 
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