Click here to Skip to main content
15,897,334 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello. I have a form that does reports. On the form I have 6 DropDownList. The main DropDownList name is Schools. The other five are years. What I want to do is to select a school from the DropDownListSchools and based on that selection the DropDownListYear will populate with the years. When I Databound the DropDownListyear it came with all the years from all the schools and no way to tell which year belongs to which school. All of the schools have an ID also. Can someone help me to see where did I go wrong? What code am I missing?

C#
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;
using System.Text;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing.Printing;
public partial class SchoolReports : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void DropDownListSchools_SelectedIndexChanged(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PassConnectionString"].ConnectionString);
        con.Open(); 
    }
    protected void DropDownListCFY1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void DropDownListCFY2_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void DropDownListCFY3_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void DropDownListCFY4_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void DropDownListCFY5_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void DropDownListFY1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void DropDownListFY2_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void DropDownListFY3_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void DropDownListFY4_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void DropDownListFY5_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}
Posted
Comments
Joezer BH 14-Aug-13 10:31am    
Your code (showing 12 DropDownLists [not 6]) is not much help.
You have no functionality in the code of the SelectedIndexChanged.
What exactly to you want to happen when someone selects from the DropDownList "Schools" ?
Computer Wiz99 14-Aug-13 10:35am    
Ok. Sorry about the code. Question, would doing the reports form be better in Gridview?

1 solution

In the DropDownListSchools_SelectedIndexChanged function perform the actions you want on the other dropdownlists!

You just don't have any code there that handleds the other DDLs
 
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