C
cindy
I have a webform, click on link "one" and usercontrol page1.ascx loads.
Page1.ascx has the dropdrop list. The data loads when control first
displayed. The postback fires when item selected. The data does not do a
reload because of if !postback check. The value returned from the list is
always ""
Code from Page1.ascx
<aspropDownList EnableViewState="True" id="drpZone" AutoPostBack="True"
runat="server"></aspropDownList>
I am using session
protected string Zone
{
get
{
return Session["Zone"] as string;
}
set
{
Session["Zone"] = value;
}
}
Before the control renders if not postback I populate list with data
private void Page1_PreRender(object sender, EventArgs e)
{
Zone = drpZone.SelectedValue;
SearchBLL bll = new SearchBLL();
bll.ZoneData(this);
}
code from SearchBLL
public void ZoneData(Page1 pageControl)
{
SearchDAL dal = new SearchDAL();
pageControl.ZoneDataSource = dal.ZoneList();
}
code from SearchDAL
public DataSet ZoneList()
{
try
{
DataSet ds = new DataSet();
// Open database connection
SqlConnection connection = new SqlConnection("Data Source=tsbucontent;
Initial Catalog=sis_applications; uid=sa; pwd=1452hd;");
SqlCommand command = new SqlCommand();
// Create SQL command
string sql="SELECT ID,NAME FROM UserLU WHERE ACTIVE = '1' and TYPE =
'Zone'";
SqlDataAdapter adapter = new SqlDataAdapter();
command.CommandText = sql;
command.Connection = connection;
adapter.SelectCommand = command;
// Fill Dataset
adapter.Fill(ds);
return ds;
}
catch //Error occured
{
throw;
//return null;
}
}
List is populated from database
I select value and postback happens, code does not go back to database to
repopulate I checked it. The event selectedindexchanged is never fired
code on Page1.ascx
private void InitializeComponent()
{
this.drpZone.SelectedIndexChanged +=new
EventHandler(drpZone_SelectedIndexChanged);
this.btnRetrieve.Click += new System.EventHandler(this.btnRetrieve_Click);
this.dgResults.ItemCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgResults_ItemCommand);
this.Load += new System.EventHandler(this.Page_Load);
this.PreRender += new System.EventHandler(this.Page1_PreRender);
}
private void drpZone_SelectedIndexChanged(object sender, EventArgs e)
{
SearchBLL bll = new SearchBLL();
bll.LCTData(this);
}
Page1.ascx has the dropdrop list. The data loads when control first
displayed. The postback fires when item selected. The data does not do a
reload because of if !postback check. The value returned from the list is
always ""
Code from Page1.ascx
<aspropDownList EnableViewState="True" id="drpZone" AutoPostBack="True"
runat="server"></aspropDownList>
I am using session
protected string Zone
{
get
{
return Session["Zone"] as string;
}
set
{
Session["Zone"] = value;
}
}
Before the control renders if not postback I populate list with data
private void Page1_PreRender(object sender, EventArgs e)
{
Zone = drpZone.SelectedValue;
SearchBLL bll = new SearchBLL();
bll.ZoneData(this);
}
code from SearchBLL
public void ZoneData(Page1 pageControl)
{
SearchDAL dal = new SearchDAL();
pageControl.ZoneDataSource = dal.ZoneList();
}
code from SearchDAL
public DataSet ZoneList()
{
try
{
DataSet ds = new DataSet();
// Open database connection
SqlConnection connection = new SqlConnection("Data Source=tsbucontent;
Initial Catalog=sis_applications; uid=sa; pwd=1452hd;");
SqlCommand command = new SqlCommand();
// Create SQL command
string sql="SELECT ID,NAME FROM UserLU WHERE ACTIVE = '1' and TYPE =
'Zone'";
SqlDataAdapter adapter = new SqlDataAdapter();
command.CommandText = sql;
command.Connection = connection;
adapter.SelectCommand = command;
// Fill Dataset
adapter.Fill(ds);
return ds;
}
catch //Error occured
{
throw;
//return null;
}
}
List is populated from database
I select value and postback happens, code does not go back to database to
repopulate I checked it. The event selectedindexchanged is never fired
code on Page1.ascx
private void InitializeComponent()
{
this.drpZone.SelectedIndexChanged +=new
EventHandler(drpZone_SelectedIndexChanged);
this.btnRetrieve.Click += new System.EventHandler(this.btnRetrieve_Click);
this.dgResults.ItemCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgResults_ItemCommand);
this.Load += new System.EventHandler(this.Page_Load);
this.PreRender += new System.EventHandler(this.Page1_PreRender);
}
private void drpZone_SelectedIndexChanged(object sender, EventArgs e)
{
SearchBLL bll = new SearchBLL();
bll.LCTData(this);
}