Is there a way for me to stop the web page from refreshing every time a user selects something from the dropdownlist? I have 11 dropdownlist and every one has a different function. Here is my code.
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");
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
}
protected void DropDownListSchools_SelectedIndexChanged(object sender, EventArgs e)
{
lblINST_ID.Text = DropDownListSchools.SelectedValue;
}
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 INST_ID, TOTASSETS, TOTLIABILITY, UNRNETASSETS, NonExppermresAssets, TotalRev, TuitFees, CurrDebt, LongTermDebt from TableFIN2009 where INST_ID = " + DropDownListCFY1.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxTA1.Text = dr["TOTASSETS"].ToString();
TextBoxTL1.Text = dr["TOTLIABILITY"].ToString();
TextBoxUNA1.Text = dr["UNRNETASSETS"].ToString();
TextBoxPRNA1.Text = dr["NonExppermresAssets"].ToString();
TextBoxTR1.Text = dr["TotalRev"].ToString();
TextBoxTFN1.Text = dr["TuitFees"].ToString();
TextBoxCD1.Text = dr["CurrDebt"].ToString();
TextBoxLDT1.Text = dr["LongTermDebt"].ToString();
int a = Convert.ToInt32(TextBoxTA1.Text);
int b = Convert.ToInt32(TextBoxTL1.Text);
TextBoxTNA1.Text = Convert.ToString(a - b);
int a1 = Convert.ToInt32(TextBoxUNA1.Text);
int b1 = Convert.ToInt32(TextBoxPRNA1.Text);
TextBoxTNAS1.Text = Convert.ToString(a1 + b1);
}
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 INST_ID, TOTASSETS, TOTLIABILITY, UNRNETASSETS, NonExppermresAssets, TotalRev, TuitFees, CurrDebt, LongTermDebt from TableFIN2010 where INST_ID = " + DropDownListCFY2.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxTA2.Text = dr["TOTASSETS"].ToString();
TextBoxTL2.Text = dr["TOTLIABILITY"].ToString();
TextBoxUNA2.Text = dr["UNRNETASSETS"].ToString();
TextBoxPRNA2.Text = dr["NonExppermresAssets"].ToString();
TextBoxTR2.Text = dr["TotalRev"].ToString();
TextBoxTFN2.Text = dr["TuitFees"].ToString();
TextBoxCD2.Text = dr["CurrDebt"].ToString();
TextBoxLTD2.Text = dr["LongTermDebt"].ToString();
int a = Convert.ToInt32(TextBoxTA2.Text);
int b = Convert.ToInt32(TextBoxTL2.Text);
TextBoxTNA2.Text = Convert.ToString(a - b);
int a2 = Convert.ToInt32(TextBoxUNA2.Text);
int b2 = Convert.ToInt32(TextBoxPRNA2.Text);
TextBoxTNAS2.Text = Convert.ToString(a2 + b2);
}
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 INST_ID, TOTASSETS, TOTLIABILITY, UNRNETASSETS, NonExppermresAssets, TotalRev, TuitFees, CurrDebt, LongTermDebt from TableFIN2011 where INST_ID = " + DropDownListCFY3.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxTA3.Text = dr["TOTASSETS"].ToString();
TextBoxTL3.Text = dr["TOTLIABILITY"].ToString();
TextBoxUNA3.Text = dr["UNRNETASSETS"].ToString();
TextBoxPRNA3.Text = dr["NonExppermresAssets"].ToString();
TextBoxTR3.Text = dr["TotalRev"].ToString();
TextBoxTFN3.Text = dr["TuitFees"].ToString();
TextBoxCD3.Text = dr["CurrDebt"].ToString();
TextBoxLTD3.Text = dr["LongTermDebt"].ToString();
int a = Convert.ToInt32(TextBoxTA3.Text);
int b = Convert.ToInt32(TextBoxTL3.Text);
TextBoxTNA3.Text = Convert.ToString(a - b);
int a3 = Convert.ToInt32(TextBoxUNA3.Text);
int b3 = Convert.ToInt32(TextBoxPRNA3.Text);
TextBoxTNAS3.Text = Convert.ToString(a3 + b3);
}
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 INST_ID, TOTASSETS, TOTLIABILITY, UNRNETASSETS, NonExppermresAssets, TotalRev, TuitFees, CurrDebt, LongTermDebt from TableFIN2012 where INST_ID = " + DropDownListCFY4.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxTA4.Text = dr["TOTASSETS"].ToString();
TextBoxTL4.Text = dr["TOTLIABILITY"].ToString();
TextBoxUNA4.Text = dr["UNRNETASSETS"].ToString();
TextBoxPRNA4.Text = dr["NonExppermresAssets"].ToString();
TextBoxTR4.Text = dr["TotalRev"].ToString();
TextBoxTFN4.Text = dr["TuitFees"].ToString();
TextBoxCD4.Text = dr["CurrDebt"].ToString();
TextBoxLTD4.Text = dr["LongTermDebt"].ToString();
int a = Convert.ToInt32(TextBoxTA4.Text);
int b = Convert.ToInt32(TextBoxTL4.Text);
TextBoxTNA4.Text = Convert.ToString(a - b);
int a4 = Convert.ToInt32(TextBoxUNA4.Text);
int b4 = Convert.ToInt32(TextBoxPRNA4.Text);
TextBoxTNAS4.Text = Convert.ToString(a4 + b4);
}
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 INST_ID, TOTASSETS, TOTLIABILITY, UNRNETASSETS, NonExppermresAssets, TotalRev, TuitFees, CurrDebt, LongTermDebt from TableFIN2013 where INST_ID = " + DropDownListCFY5.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxTA5.Text = dr["TOTASSETS"].ToString();
TextBoxTL5.Text = dr["TOTLIABILITY"].ToString();
TextBoxUNA5.Text = dr["UNRNETASSETS"].ToString();
TextBoxPRNA5.Text = dr["NonExppermresAssets"].ToString();
TextBoxTR5.Text = dr["TotalRev"].ToString();
TextBoxTFN5.Text = dr["TuitFees"].ToString();
TextBoxCD5.Text = dr["CurrDebt"].ToString();
TextBoxLTD5.Text = dr["LongTermDebt"].ToString();
int a = Convert.ToInt32(TextBoxTA5.Text);
int b = Convert.ToInt32(TextBoxTL5.Text);
TextBoxTNA5.Text = Convert.ToString(a - b);
int a5 = Convert.ToInt32(TextBoxUNA5.Text);
int b5 = Convert.ToInt32(TextBoxPRNA5.Text);
TextBoxTNAS5.Text = Convert.ToString(a5 + b5);
}
dr.Close();
con.Close();
}
protected void DropDownListFY1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
SqlCommand scmd = new SqlCommand("Select INST_ID, TOTAL_FTE from TableFTE2009 where INST_ID = " + DropDownListFY1.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxEPCOC1.Text = dr["TOTAL_FTE"].ToString();
}
dr.Close();
con.Close();
}
protected void DropDownListFY2_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
SqlCommand scmd = new SqlCommand("Select INST_ID, TOTAL_FTE from TableFTE2010 where INST_ID = " + DropDownListFY2.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxEPCOC2.Text = dr["TOTAL_FTE"].ToString();
}
dr.Close();
con.Close();
}
protected void DropDownListFY3_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
SqlCommand scmd = new SqlCommand("Select INST_ID, TOTAL_FTE from TableFTE2011 where INST_ID = " + DropDownListFY3.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxEPCOC3.Text = dr["TOTAL_FTE"].ToString();
}
dr.Close();
con.Close();
}
protected void DropDownListFY4_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
SqlCommand scmd = new SqlCommand("Select INST_ID, TOTAL_FTE from TableFTE2012 where INST_ID = " + DropDownListFY4.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxEPCOC4.Text = dr["TOTAL_FTE"].ToString();
}
dr.Close();
con.Close();
}
protected void DropDownListFY5_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
SqlCommand scmd = new SqlCommand("Select INST_ID, TOTAL_FTE from TableFTE2013 where INST_ID = " + DropDownListFY5.SelectedValue.ToString(), con);
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxEPCOC5.Text = dr["TOTAL_FTE"].ToString();
}
dr.Close();
con.Close();
}
}