473,748 Members | 9,416 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 7959
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
1936
by: Jay | last post by:
I have dropdownlist in a usercontrol and selectedindexchange event captured. But Iam seeing fire twice. Thanks.
2
5079
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
2076
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
1754
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
2286
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
3221
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
1055
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
1463
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
9847
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
9530
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
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...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
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
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
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
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
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.