473,326 Members | 2,133 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,326 software developers and data experts.

call OnSelectedIndexChanged??

Does somebody knows, if there's a way to call the OnSelectedIndexChanged method of the dropdownlist by myself?

Or does somebody knows a way, to raise the SelectedIndexChanged Event of a dropdownlist?

tia
Martin
Nov 18 '05 #1
2 1901
Hi Martin,

You should be able to call the subroutine on your own as long as you pass
the parameters it expects.

Here's a way to do it on a button click:

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim earg As New EventArgs
Call DropDownList1_SelectedIndexChanged _
(DropDownList1, earg.Empty)
End Sub

Private Sub DropDownList1_SelectedIndexChanged _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles DropDownList1.SelectedIndexChanged
Button1.Text = _
DropDownList1.SelectedValue.ToString
End Sub

<P>
<asp:DropDownList id="DropDownList1" runat="server">
<asp:ListItem Value="Red">Red</asp:ListItem>
<asp:ListItem Value="Green">Green</asp:ListItem>
<asp:ListItem Value="Blue">Blue</asp:ListItem>
</asp:DropDownList></P>
<P>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></P>

Is this what you meant?

Ken
Microsoft MVP [ASP.NET]
Toronto
"Martin" <Ma****@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
Does somebody knows, if there's a way to call the OnSelectedIndexChanged
method of the dropdownlist by myself?

Or does somebody knows a way, to raise the SelectedIndexChanged Event of a
dropdownlist?

tia
Martin


Nov 18 '05 #2
Thx for the reply but this is not what I mean, the problem is much more complicated.
I have the object of the dropdownlist, but I don't know how the eventhandler is called.

I am in a class outside of the page of the dropdownlist !

"Ken Cox [Microsoft MVP]" wrote:
Hi Martin,

You should be able to call the subroutine on your own as long as you pass
the parameters it expects.

Here's a way to do it on a button click:

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim earg As New EventArgs
Call DropDownList1_SelectedIndexChanged _
(DropDownList1, earg.Empty)
End Sub

Private Sub DropDownList1_SelectedIndexChanged _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles DropDownList1.SelectedIndexChanged
Button1.Text = _
DropDownList1.SelectedValue.ToString
End Sub

<P>
<asp:DropDownList id="DropDownList1" runat="server">
<asp:ListItem Value="Red">Red</asp:ListItem>
<asp:ListItem Value="Green">Green</asp:ListItem>
<asp:ListItem Value="Blue">Blue</asp:ListItem>
</asp:DropDownList></P>
<P>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></P>

Is this what you meant?

Ken
Microsoft MVP [ASP.NET]
Toronto
"Martin" <Ma****@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
Does somebody knows, if there's a way to call the OnSelectedIndexChanged
method of the dropdownlist by myself?

Or does somebody knows a way, to raise the SelectedIndexChanged Event of a
dropdownlist?

tia
Martin


Nov 18 '05 #3

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

Similar topics

0
by: Jon Maz | last post by:
Hi, I have a user control which contains a DropDownList, and I want to be able to set the OnSelectedIndexChanged method of the DDL in the User Control from the holding aspx page. Depending on...
6
by: DotNetGruven | last post by:
I have a webform that has a DataGrid on it with a RadioButtonList in each row. It is a simple On & Off. When the User Clicks on either of the RadioButtons, I need to postback to the server and...
6
by: srallen | last post by:
I have a simple page that has a dropdown with autopostback=true and onselectedindexchanged is set to a function that never gets called (checked during debug). This page is subclassed from custom...
1
by: RedGST | last post by:
Hello, Im somewhat new to asp.net, so bear with me. I have created a form that has a Listbox along with 2 command buttons & a few other non-important controls. The command button is tied to...
6
by: Olivier Matrot | last post by:
Hello, This has probably been asked several times, but It must be clarified for me. I would like to know why sometimes during a postback Page_Load is called after the function marked for...
0
by: Bengt-Erik Eliasson | last post by:
Hi! In a DataGrid I have a 'Add New'-field in the footer. I want to hide an control (txtNewFe_name) if the value of cmbNewFe_num is >0. How do I do that? The OnSelectedIndexChanged does not seem...
0
by: Bengt-Erik Eliasson | last post by:
Hi! In a DataGrid I have a 'Add New'-field in the footer. I want to hide an control (txtNewFe_name) if the value of cmbNewFe_num is >0. How do I do that? The OnSelectedIndexChanged does not...
2
by: glenn | last post by:
Hi folks, I am trying to determine which item in a DropDownList Web control has been selected. I have posted an OnSelectedIndexChanged subroutine in my code with a reference to the subroutine...
1
by: Groove | last post by:
I have a strange problem. It seems that for some reason, a OnSelectedIndexChanged event is no producing an error in IE6. What concerns me is that I just performed that large Windows update a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.