473,763 Members | 4,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple Calls to DropDownList SelectedIndexCh ange event

Can anyone tell me why I am getting 2 calls to my SelectedIndexCh ange
event.

public class Browse : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid DataGrid1;
protected System.Web.UI.W ebControls.Drop DownList DropDownConf;
protected DataSet BrowseOrders=nu ll;
protected int ConfID;
private void Page_Load(objec t sender, System.EventArg s e)
{

if ( Session["ConfID"]==null)
Session["ConfID"] = 3;
if (!IsPostBack)
{
BindData(null);
}
//Conference Dropdown Menu
DataSet conferences = RegCache.Confer enceList();
DropDownConf.Da taTextField = "ConfName";
DropDownConf.Da taValueField = "ConfID";
DropDownConf.Da taSource = conferences;
DropDownConf.Da taBind();

ListItem item = new ListItem("- Choose Conference -", "");
DropDownConf.It ems.Insert(0,it em);
}
private void BindData (string orderBy)
{
ConfID = Convert.ToInt32 (Session["ConfID"]);
orderBy =(orderBy==null )?"OrderID":ord erBy;
DataSet ds = null;
if (ViewState["BrowseData Set"]==null)
{
ds = Data.DataAccess .BrowseOrders(C onfID); //create data set and add
to view state
ViewState.Add(" BrowseDataSet", ds);
ds.Tables[0].DefaultView.So rt=orderBy;
}
else
{
ds=(DataSet)Vie wState["BrowseData Set"]; //get data set from view
state

ds.Tables[0].DefaultView.So rt=orderBy;
}
DataGrid1.DataS ource = ds.Tables[0].DefaultView;
DataGrid1.DataB ind();
}
public void SortDataGrid(Ob ject sender, DataGridSortCom mandEventArgs
e)
{
BindData(e.Sort Expression);

}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.DropDownCo nf.SelectedInde xChanged += new
System.EventHan dler(this.DropD ownConf_Selecte dIndexChanged);

this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion


public void DropDownConf_Se lectedIndexChan ged(object sender,
System.EventArg s e)
{
Session["ConfID"] = DropDownConf.Se lectedItem.Valu e;
ViewState.Remov e("BrowseDataSe t");
BindData(null);
}
}

Thanks,
Paul

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
1 7963
Hi,

Look at the following code snippet:

private void InitializeCompo nent()
{
this.DropDownCo nf.SelectedInde *xChanged += new

System.EventHan dler(this.DropD *ownConf_Select edIndexChanged) ;
this.Load += new
System.EventHan dler(this.Page_ *Load);
}

Here you are binding your dropdown selected Index Changed event with
the eventhandler. I am afraid that you might have done the same thing
in the corresponding aspx file also. So there are two calls one from
..aspx and other from .aspx.cs file.

Don't know why this happens but it happens only when you write the code
behind using C#. If you use VB.NET then it is intelligent enough to
make this call only once.

HTH,
Regards,
Angrez

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1938
by: Jay | last post by:
I have dropdownlist in a usercontrol and selectedindexchange event captured. But Iam seeing fire twice. Thanks.
2
5081
by: MBhat | last post by:
Hello, I have a dropdownlist server control.On selectedIndexChange I do some functionality. In addtion to this I need to check for something else. To do this I have to use javascript function to display confirmation alert. How can I use the javascript confirmation alert in code behind? any help? Thanks
4
2077
by: Yahya Saad | last post by:
Dear All, I have an ASP.Net webform that includes a DropDownList (bound to a dataview including 6000 records) and a textbox that is updated according to the selection of an event at the SelectedIndexChange of the DropDownList. Filling the DropDownList takes about 3 seconds but when the SelectedIndex of the DropDownList is changed it takes about a minute for the webform to respond. How can i speed up my pages response, knowing that I have...
1
1755
by: NH | last post by:
Hi, I want to filter records that display in some asp.net dropdownlists without causing a postback. Any ideas? e.g. when the selectedindexchange event fires for dropdownlist1 then only certain records are displayed in dropdownlist 2. I know how to add a client side javascript event to the dropdownlist but I dont know how to.. 1: Filter out records in dropdownlist2 without a postback
0
2288
by: Tand35006 | last post by:
Hi, I hope some one can help with this. I have a basic webform with 2 DropDownLists and a single DataGrid. What I am trying to do is populate the first DDList from a dataset on Form_Load. I then want to use this 1st DDList to populate the 2nd DDList via the SelectedIndexChange Event. So far so good. all works up to this point. The next thing I'm trying to do is to use the 2nd DDList value in a queery to populate the Datagrid also...
2
3222
by: Kevin | last post by:
Hi I need to get the "ItemId" from the selected value of the DropDownList in a DataList, but i don't known where tu put the <%# DataBinder.Eval(Container.DataItem, "ItemId"), because if I try to put in the ID of the DropDownList generate an error. I've used this code, i catch the SelectedIndexChange. HTML: <asp:DataList id="dlDropDownList" runat="server"> <ItemTemplate>
0
1056
by: kimberly.walker | last post by:
I have a user control with 3 dropdownlist when a user selects the first listbox based on his/her selection the 2 listbox will load based off the users selection from the 2nd listbox the 3rd listbox will load. My problem is the first listbox works but when the user selects the 2nd listbox the event fires but not in the selectedindexchange event all of the dropdownlist have autopostback set to true. I have debug and found that when I...
3
1466
by: Kim | last post by:
I have a user control with 3 dropdownlist when a user selects the first listbox based on his/her selection the 2 listbox will load based off the users selection from the 2nd listbox the 3rd listbox will load. My problem is the first listbox works but when the user selects the 2nd listbox the event fires but not in the selectedindexchange event all of the dropdownlist have autopostback set to true. I have debug and found that when I...
3
9848
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
Hi, Trouble in retaining values of dropdownlist, textboxes, and other controls when dropdownlist selectedindexchanged event is triggered, the controls are inside a user control and this user control inside a parent user control with an update panel. Can you guys help me hwo to retain the values. I have set EnableViewState to true. Where is correct page event to store entered and selected values before the values on controls are...
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9997
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.