Hello to all. I have a problem with my DDLs. I have a total of 11 of them. The main DDL has school names in them. The others have years in them. Tjhey all are databound and the value is the INST_ID. When I select a school in the main DDL it should populate the other DDL with only the years from that school but I get the years from all the school and I have to count the years from the selection of the school. Next I also have the selection of the year to populate the textboxes that are in the form. That part works so far but when I go to other DDL they all rest back to the first year. Why is that happening and what did I do wrong?
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)
{
ButtonPrint.Attributes.Add("onclick", "window.print(); return false");
}
protected void DropDownListSchools_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
}
protected void DropDownListCFY1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
SqlCommand scmd = new SqlCommand("Select FINYR, TOTASSETS, TOTLIABILITY, UNRNETASSETS from TableFIN where INST_ID = " + DropDownListCFY1.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxTA1.Text = dr["TOTASSETS"].ToString();
TextBoxTL1.Text = dr["TOTLIABILITY"].ToString();
TextBoxTNA1.Text = dr["UNRNETASSETS"].ToString();
}
dr.Close();
con.Close();
}
protected void DropDownListCFY2_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
SqlCommand scmd = new SqlCommand("Select FINYR, TOTASSETS, TOTLIABILITY, UNRNETASSETS from TableFIN where INST_ID = " + DropDownListCFY2.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxTA2.Text = dr["TOTASSETS"].ToString();
TextBoxTL2.Text = dr["TOTLIABILITY"].ToString();
TextBoxTNA2.Text = dr["UNRNETASSETS"].ToString();
}
dr.Close();
con.Close();
}
protected void DropDownListCFY3_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
SqlCommand scmd = new SqlCommand("Select FINYR, TOTASSETS, TOTLIABILITY, UNRNETASSETS from TableFIN where INST_ID = " + DropDownListCFY3.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxTA3.Text = dr["TOTASSETS"].ToString();
TextBoxTL3.Text = dr["TOTLIABILITY"].ToString();
TextBoxTNA3.Text = dr["UNRNETASSETS"].ToString();
}
dr.Close();
con.Close();
}
protected void DropDownListCFY4_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
SqlCommand scmd = new SqlCommand("Select FINYR, TOTASSETS, TOTLIABILITY, UNRNETASSETS from TableFIN where INST_ID = " + DropDownListCFY4.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxTA4.Text = dr["TOTASSETS"].ToString();
TextBoxTL4.Text = dr["TOTLIABILITY"].ToString();
TextBoxTNA4.Text = dr["UNRNETASSETS"].ToString();
}
dr.Close();
con.Close();
}
protected void DropDownListCFY5_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
SqlCommand scmd = new SqlCommand("Select FINYR, TOTASSETS, TOTLIABILITY, UNRNETASSETS from TableFIN where INST_ID = " + DropDownListCFY5.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxTA5.Text = dr["TOTASSETS"].ToString();
TextBoxTL5.Text = dr["TOTLIABILITY"].ToString();
TextBoxTNA5.Text = dr["UNRNETASSETS"].ToString();
}
dr.Close();
con.Close();
}
protected void DropDownListFY1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
}
protected void DropDownListFY2_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
}
protected void DropDownListFY3_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void DropDownListFY4_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
}
protected void DropDownListFY5_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
}
}