P
Paul C
Can anyone tell me why I am getting 2 calls to my SelectedIndexChange
event.
public class Browse : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.DropDownList DropDownConf;
protected DataSet BrowseOrders=null;
protected int ConfID;
private void Page_Load(object sender, System.EventArgs e)
{
if ( Session["ConfID"]==null)
Session["ConfID"] = 3;
if (!IsPostBack)
{
BindData(null);
}
//Conference Dropdown Menu
DataSet conferences = RegCache.ConferenceList();
DropDownConf.DataTextField = "ConfName";
DropDownConf.DataValueField = "ConfID";
DropDownConf.DataSource = conferences;
DropDownConf.DataBind();
ListItem item = new ListItem("- Choose Conference -", "");
DropDownConf.Items.Insert(0,item);
}
private void BindData (string orderBy)
{
ConfID = Convert.ToInt32(Session["ConfID"]);
orderBy =(orderBy==null)?"OrderID"
rderBy;
DataSet ds = null;
if (ViewState["BrowseDataSet"]==null)
{
ds = Data.DataAccess.BrowseOrders(ConfID); //create data set and add
to view state
ViewState.Add("BrowseDataSet",ds);
ds.Tables[0].DefaultView.Sort=orderBy;
}
else
{
ds=(DataSet)ViewState["BrowseDataSet"]; //get data set from view
state
ds.Tables[0].DefaultView.Sort=orderBy;
}
DataGrid1.DataSource = ds.Tables[0].DefaultView;
DataGrid1.DataBind();
}
public void SortDataGrid(Object sender, DataGridSortCommandEventArgs
e)
{
BindData(e.SortExpression);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.DropDownConf.SelectedIndexChanged += new
System.EventHandler(this.DropDownConf_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public void DropDownConf_SelectedIndexChanged(object sender,
System.EventArgs e)
{
Session["ConfID"] = DropDownConf.SelectedItem.Value;
ViewState.Remove("BrowseDataSet");
BindData(null);
}
}
Thanks,
Paul
event.
public class Browse : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.DropDownList DropDownConf;
protected DataSet BrowseOrders=null;
protected int ConfID;
private void Page_Load(object sender, System.EventArgs e)
{
if ( Session["ConfID"]==null)
Session["ConfID"] = 3;
if (!IsPostBack)
{
BindData(null);
}
//Conference Dropdown Menu
DataSet conferences = RegCache.ConferenceList();
DropDownConf.DataTextField = "ConfName";
DropDownConf.DataValueField = "ConfID";
DropDownConf.DataSource = conferences;
DropDownConf.DataBind();
ListItem item = new ListItem("- Choose Conference -", "");
DropDownConf.Items.Insert(0,item);
}
private void BindData (string orderBy)
{
ConfID = Convert.ToInt32(Session["ConfID"]);
orderBy =(orderBy==null)?"OrderID"

DataSet ds = null;
if (ViewState["BrowseDataSet"]==null)
{
ds = Data.DataAccess.BrowseOrders(ConfID); //create data set and add
to view state
ViewState.Add("BrowseDataSet",ds);
ds.Tables[0].DefaultView.Sort=orderBy;
}
else
{
ds=(DataSet)ViewState["BrowseDataSet"]; //get data set from view
state
ds.Tables[0].DefaultView.Sort=orderBy;
}
DataGrid1.DataSource = ds.Tables[0].DefaultView;
DataGrid1.DataBind();
}
public void SortDataGrid(Object sender, DataGridSortCommandEventArgs
e)
{
BindData(e.SortExpression);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.DropDownConf.SelectedIndexChanged += new
System.EventHandler(this.DropDownConf_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public void DropDownConf_SelectedIndexChanged(object sender,
System.EventArgs e)
{
Session["ConfID"] = DropDownConf.SelectedItem.Value;
ViewState.Remove("BrowseDataSet");
BindData(null);
}
}
Thanks,
Paul