473,385 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

1
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 selectedindexchange 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 2805
markrawlingson
346 Expert 100+
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
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...
0
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
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 =...
4
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
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...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
3
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...
6
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...

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.