473,395 Members | 1,668 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,395 software developers and data experts.

Raising event from run-time dropdownlist

I'm creating DropDownList controls at run-time, and I've found I have to add
the onchange event myself (.Attributes.Add(...) below).

Is that the way it's meant to happen, or have I missed something that would
automatically add the onchange event?

U = New DropDownList
With U
.DataSource = dv
.DataTextField = "myChoice"
.DataValueField = "myValue"
.DataBind()
' n is the number of this control
.ID = "U_" & n.ToString
' select the current value
For k As Integer = 0 To UBound(usageValues)
If CStr(entry("usage")) = usageValues(k) Then
.SelectedIndex = k
Exit For
End If
Next
AddHandler .SelectedIndexChanged, AddressOf
ModifyUsage_SelectedIndexChanged
.Attributes.Add("onchange", "__doPostBack('U_" & n.ToString & "')")
End With

Andrew
Sep 19 '07 #1
2 1367
you want to set AutoPostBack.

-- bruce (sqlwork.com)

Andrew Morton wrote:
I'm creating DropDownList controls at run-time, and I've found I have to add
the onchange event myself (.Attributes.Add(...) below).

Is that the way it's meant to happen, or have I missed something that would
automatically add the onchange event?

U = New DropDownList
With U
.DataSource = dv
.DataTextField = "myChoice"
.DataValueField = "myValue"
.DataBind()
' n is the number of this control
.ID = "U_" & n.ToString
' select the current value
For k As Integer = 0 To UBound(usageValues)
If CStr(entry("usage")) = usageValues(k) Then
.SelectedIndex = k
Exit For
End If
Next
AddHandler .SelectedIndexChanged, AddressOf
ModifyUsage_SelectedIndexChanged
.Attributes.Add("onchange", "__doPostBack('U_" & n.ToString & "')")
End With

Andrew

Sep 19 '07 #2
Andrew Morton wrote:
>I'm creating DropDownList controls at run-time, and I've found I
have to add the onchange event myself (.Attributes.Add(...) below).

Is that the way it's meant to happen, or have I missed something
that would automatically add the onchange event?
bruce barker wrote:
you want to set AutoPostBack.
Aha! Thanks :-)

Andrew
Sep 20 '07 #3

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

Similar topics

3
by: The Mess | last post by:
I am working in VB5. How do you mimmick Visual Basic's putting an Index argument at the front of the variables passed to an event when making your own control? This sounds kind of confusing so...
1
by: Rajesh.V | last post by:
I have made a custom control in asp.net using webcontrols, and am raising my event. I find that if no control is hooked into the event it goes for a toss. I tried to find length of the delegate...
6
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
0
by: Joe Campbell | last post by:
I am encountering a problem raising WMI events from an asp.net application. The error received (as captured in the event log) is as follows: System.Runtime.InteropServices.COMException...
4
by: Dave A | last post by:
I am developing a somewhat complex component at the moment and coincidently I am also reading the Framework Design Guidelines book. After reading the section about event raising I have re-written...
2
by: Gman | last post by:
Hi, I have created a usercontrol, a grid control essentially. Within it I have a class: clsGridRecord. I have coded the events such that when a user clicks on the grid, say, the events occur on...
4
by: sloan | last post by:
I"m trying to figure out what concept I'm missing here, or if its not a good idea .. or what. Here is my example.. code is below. I have an employee class. It has an event that can be raised....
0
by: Apu Nahasapeemapetilon | last post by:
Suggestions on cross-posting this issue would be appreciated. I've got a C# .NET DLL (CLR v1.1) that raises events into its container. When the container is a .NET application, raising the...
2
by: =?Utf-8?B?Um9i?= | last post by:
I'm new to event processing in vs 2005 - what I'm trying to achieve is broadly a network simulation of two workstations sending packets to each other . I have defined a class 'Workstation' and I...
7
by: Christian Cambier | last post by:
Hi, I have a textbox in a web user control. I then add the usercontrol to a web form. I also add a label in the web form. Now, when I press a key in the textbox, i want to display some text...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
0
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...

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.