G
Guest
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 in my asp tag as shown here:
<aspropDownList
id="ddlTo"
runat="server"
DataValueField="cname"
AutoPostBack="True"
DataSource='<%# GetCompanyNamesForThisProject() %>'
OnSelectedIndexChanged="ddlTo_SelectedIndexChanged"
/>
My subroutine has a Response.Write inside to see if the event is fired as
shown here:
Sub ddlTo_SelectedIndexChanged(sender As Object, e As EventArgs)
Response.Write ("your dropdownlist event has fired")
End Sub
I successfully have fired the event when I select an item in the
dropdownlist control where the text "your dropdownlist event has fired"
writes to the screen.
Unfortunately, when I attempt to get the index number of the item I
selected, I get an error stating that ddlTo is not declared. ddlTo is the id
that was set in the <aspropDownList tag.
Sub ddlTo_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim indexNum as integer
indexNum = ddlTo.SelectedIndex
Response.Write(indexNum )
End Sub
It seems to me that ddlTo was declared in the asp tag as the id. How else
should I be declaring ddlTo?
Thanks for any help on this...
Glenn
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 in my asp tag as shown here:
<aspropDownList
id="ddlTo"
runat="server"
DataValueField="cname"
AutoPostBack="True"
DataSource='<%# GetCompanyNamesForThisProject() %>'
OnSelectedIndexChanged="ddlTo_SelectedIndexChanged"
/>
My subroutine has a Response.Write inside to see if the event is fired as
shown here:
Sub ddlTo_SelectedIndexChanged(sender As Object, e As EventArgs)
Response.Write ("your dropdownlist event has fired")
End Sub
I successfully have fired the event when I select an item in the
dropdownlist control where the text "your dropdownlist event has fired"
writes to the screen.
Unfortunately, when I attempt to get the index number of the item I
selected, I get an error stating that ddlTo is not declared. ddlTo is the id
that was set in the <aspropDownList tag.
Sub ddlTo_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim indexNum as integer
indexNum = ddlTo.SelectedIndex
Response.Write(indexNum )
End Sub
It seems to me that ddlTo was declared in the asp tag as the id. How else
should I be declaring ddlTo?
Thanks for any help on this...
Glenn