473,569 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do i handle the Selected Index Changed event of a dynamic DropDownList

1 New Member
could someone help me out with this??

i am creating a dropdown(dd2) dynamically inside a <div> , on the selected index event of another dropdown(dd1). somehow i am not able to handle or get the selectedindexch ange event of dd2. i get the values inside dd2, but does not respond to any event. i am using

the code is as below.

Expand|Select|Wrap|Line Numbers
  1. Function getdatafromdb(ByVal s As String) As String
  2.  
  3. Try
  4. dtChild = New DataTable
  5. Select Case Trim(s).ToUpper
  6. Case UCase("sivsetupid"), UCase("sub"), UCase("subclient"), UCase("edm_id"), UCase("convrt_who"), UCase("audit_who"), UCase("siv_inject"), UCase("engine_built"), UCase("audit")
  7. 'Session("tblname") = "p"
  8. qrystr2 = "select distinct " + Trim(s) + " from edi_parent order by " + Trim(s) + ""
  9. Case UCase("carrname"), UCase("scac")
  10. qrystr2 = "select distinct " + Trim(s) + " from carreuro order by " + Trim(s) + ""
  11. 'Session("tblname") = "ca"
  12. Case UCase("clientname"), UCase("clientno")
  13. 'Session("tblname") = "cl"
  14. qrystr2 = "select distinct " + Trim(s) + " from clientdt order by " + Trim(s) + ""
  15. End Select
  16.  
  17. mycmd = New MySqlCommand(qrystr2, myconn)
  18. mycmd.CommandTimeout = 0
  19. adap = New MySqlDataAdapter(mycmd)
  20. adap.Fill(dtChild)
  21.  
  22. Dim ddlfiltervalue As New DropDownList 
  23. ddlfiltervalue.ID = "ddlfiltervalue"
  24. ddlfiltervalue.DataSource = dtChild
  25. ddlfiltervalue.Items.Add("--SELECT--")
  26. ddlfiltervalue.DataTextField = s
  27. ddlfiltervalue.DataBind()
  28. Me.Controls.Add(ddlfiltervalue)
  29.  
  30. Dim sw As New StringWriter
  31. Dim htw As New HtmlTextWriter(sw)
  32. ddlfiltervalue.RenderControl(htw)
  33. Return sw.ToString
  34. Catch ex As Exception
  35. Response.Write("Error filling data in child Grid" + ex.Message)
  36. Finally
  37. myconn.Close()
  38. End Try
  39. End Function
  40.  
Feb 26 '08 #1
1 2812
markrawlingson
346 Recognized Expert Contributor
Hi rk800,


Please use code tags when you post. It makes it difficult for us to sift through code in order to help you when the code isn't formatted. Instructions for this are on the right when you post.

As per your problem, I think you're trying to perform a certain action when someone chooses an option from the first drop down, you'd like to do something to second drop down? Or do you just want to know generically how to handle changes with the selectedIndex of a drop down list?

If neither of these are the case please be more clear as to what you are trying to achieve.

To handle the selectedIndex changes of a drop down list, you need to use the OnChange event in javascript which fits into your <Select> tag.

EG
Expand|Select|Wrap|Line Numbers
  1. <select name="oWhatever" OnChange="SomeJSFunction();">
  2.  
  3. </select>
  4.  
Sincerely,
Mark
Feb 26 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1679
by: Billy Jacobs | last post by:
Fairly Complicated Problem: 1. I have a C# web application. 2. I have a web form with 3 drop down list controls and other text box controls for updating user information. 3. There is a submit button. 4. On the page_load of the webform I databind three dropdownlist controls to a different datareaders. Results: 1. When I run the page...
0
1107
by: Julie Barnet | last post by:
Can someone please post a small example of how to trap a selected index changed event from a dropdownlist in a datagrid? Thanks in advance Julie Barnet
10
10727
by: dhnriverside | last post by:
Hi guys Still having a problem with this dropdownlist. Basically, I've got 4. The first 2 work fine, then my code crashes on the 3rd. ddlEndTimeHour.Items.FindByValue(endTime).Selected = true; Where endTime is a string containing "15".
4
2095
by: wolfgang wagner | last post by:
hi all! after successfully integrating a dropdownlist in my datagrid i have another problem: i cannot set the selected index of the dropdownlistbox. here is my code: hardware.aspx -------------
5
13840
by: Steve Jones | last post by:
Hi there, I am working with web forms, and am finding that the standard list of combo box events is dramatically reduced when using the dropdownlist. For example, the only event that I can see that will trigger when a user selects a different menu item is 'selected index changed'. I can confirm with a separate button that the index has...
11
5792
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
3
5273
by: Iain | last post by:
Hi All I have 2 DropDownList boxes on a page. The first (id= "Operation") is populated on PageLoad with the contents of a database table. The second id="WorkStations" will not be populated until the first has been changed The definitions are below.
6
3499
Frinavale
by: Frinavale | last post by:
I have a control that is supposed to allow the user to either allow or cancel what they were doing. When I apply this to a <select> element (or DropDownList), I cannot save the original value to restore it later. The following JavaScript is a "property" that loops through all of the controls associated with the custom confirm control...
0
7694
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...
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8118
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...
1
5504
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...
0
5217
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...
0
3651
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...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
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
0
936
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...

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.