Click here to Skip to main content
15,901,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello guys.

i have a problem in filtering my dropdown.
i have two dropdown button.
the first dropdown is ok. it runs.
but in my other dropdown. nothing happens.

i use the database from my first dropdown.
but when i use it again to my another dropdown.

nothing happens.

i hope you could help me.

thank you.

OP's Code:

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="SELECT [ID], [CourseTitle], [Discipline], [Status], [Date_Modified], [Date_Created], [Date_Approved], [Last_Modified_By] FROM [tblTrainingPlan]" DeleteCommand="DELETE FROM [tblTrainingPlan] WHERE [ID] = @ID" InsertCommand="INSERT INTO [tblTrainingPlan] ([CourseTitle], [Discipline], [Status], [Date_Modified], [Date_Created], [Date_Approved], [Last_Modified_By]) VALUES (@CourseTitle, @Discipline, @Status, @Date_Modified, @Date_Created, @Date_Approved, @Last_Modified_By)" UpdateCommand="UPDATE [tblTrainingPlan] SET [CourseTitle] = @CourseTitle, [Discipline] = @Discipline, [Status] = @Status, [Date_Modified] = @Date_Modified, [Date_Created] = @Date_Created, [Date_Approved] = @Date_Approved, [Last_Modified_By] = @Last_Modified_By WHERE [ID] = @ID">
        <selectparameters>
       <asp:controlparameter controlid="type" name="Discipline" propertyname="SelectedValue" Type="DBNull" />
       </selectparameters>
        <deleteparameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </deleteparameters>
        <updateparameters>
            <asp:Parameter Name="CourseTitle" Type="String" />
            <asp:Parameter Name="Discipline" Type="String" />
            <asp:Parameter Name="Status" Type="String" />
            <asp:Parameter Name="Date_Modified" Type="String" />
            <asp:Parameter Name="Date_Created" Type="String" />
            <asp:Parameter Name="Last_Modified_By" Type="String" />
            <asp:Parameter Name="ID" Type="Int32" />
        </updateparameters>
        <insertparameters>
            <asp:Parameter Name="CourseTitle" Type="String" />
            <asp:Parameter Name="Discipline" Type="String" />
            <asp:Parameter Name="Status" Type="String" />
            <asp:Parameter Name="Date_Modified" Type="String" />
            <asp:Parameter Name="Date_Created" Type="String" />
            <asp:Parameter Name="Last_Modified_By" Type="String" />
        </insertparameters>

-chaosgray-
Posted
Updated 18-May-11 19:38pm
v5
Comments
saxenaabhi6 18-May-11 20:19pm    
your heading is not matching your question where is the gridview in your question ?
do you want to populate the second dropdown based on the value of first dropdown ?
or you populating both dropdowns from database at the same time ?
chaosgray 18-May-11 20:32pm    
im populating both dropdowns from database at the same time.
saxenaabhi6 18-May-11 21:45pm    
show the code
chaosgray 18-May-11 22:13pm    
im not coding. im just using the datasource.
Nithin Sundar 19-May-11 0:32am    
I got a notification that you posted a comment. I think you deleted it. I hope you have found your solution. The Property is like for example "SelectedValue" property of the combo box. This will filter the GridView based on the selected value in the combo box.

Moved to question since it is not an answer.
 
Share this answer
 
v2
Comments
Nithin Sundar 19-May-11 1:27am    
I can see one thing which is wrong. In type you have given "DBNull" for the control parameter. What is DBNull? You need to give a type which is like String or so depending on what type of data you are trying to filter.

By the way I'm moving this to the question.
chaosgray 19-May-11 1:35am    
i changed it to string. but nothing happens.
Nithin Sundar 19-May-11 1:42am    
Hmm that's weird. It's working for me. Are you sure that the controlID and the name you have passed are correct?
With your SQL Data source, you can filter your GridView using this method:

First you provide your basic information for the data source:

<asp:sqldatasource id="DATASOURCENAME" runat="server" connectionstring="YOUR CONNECTION STRING HERE" SelectCommand = "YOUR SELECT STATEMENT HERE">


Now, below that you specify what will be called as the Control Parameter from which the data can be filtered. In this case, a combo box or a drop down.

<selectparameters>

<asp:controlparameter controlid="THE COMBO BOX CONTROL NAME" name="THE COLUMN WHICH YOU WANT TO FILTER" propertyname="PROPERTY NAME" Type="THE DATA TYPE WHICH IS BEING FILTERED" />
                                                                                           
</selectparameters>


And then, you need to close off the SQLDataSource tag.

</asp:sqldatasource>



You can add as many parameters as required to control the data being displayed on the grid. However, watch out for Server postbacks.
 
Share this answer
 
v6
Comments
chaosgray 19-May-11 0:34am    
nothing happens. why?
Nithin Sundar 19-May-11 1:07am    
Could you update your question with what you did?
chaosgray 19-May-11 1:11am    
i just follow your instruction.
Nithin Sundar 19-May-11 1:12am    
Yeah but what is the problem? It shows an error or it doesn't work? It would be more clear if you post your sqldatasource code in the question above. Until then it is too hard to help since I don't know where you might be going wrong.
<templatefield>
<itemtemplate>
<asp:dropdownlist id="ddl2" runat="server" autopostback="true" onselectedindexchanged="ddl1_changed">
...
</templatefield>

protected void ddl1_changed(object sender,EventArgs e)
{
//filter here using ddl1.selectedvalue.
}
 
Share this answer
 

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