Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DropDownList.SelectedValue Member 1

Status
Not open for further replies.

Mike555

Technical User
Feb 21, 2003
1,200
US
I have a datagrid with column #3 as a drop down list. I'm creating an UpdateCommand event to handle changes made to that column by a user in EDIT mode.

I'm attempting to use the .SelectedValue member to identify when updates are made to that column. However, it appears that .SelectedValue is representing the previous value that the ddl had, not the updated value that was changed in EDIT mode. For example - If a user changes Column 3 from "A" to "B", SelectedValue still shows "A".

Am I using .SelectedValue correctly, or should I use another means to retrieve the changed value? Thanks.


Code:
    Private Sub DataGrid1_UpdateCommand(ByVal source As Object, _
    ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) _
    Handles DataGrid1.UpdateCommand

        'Identify the DropDown List being used
        Dim DDL As DropDownList = _
          CType(e.Item.Cells(2).Controls(1), DropDownList)

        'Newly Selected Value
        Dim NewSpecie As String = DDL.SelectedValue

--
Mike
 
Try DDL.SelectedItem.Value, like I suggested in the other post. I've never used SelectedValue. All these collections and properties get confusing.
 
I have to agree with you on that point. Unfortunately SelectedItem.Value gives the same result. Thanks, though

--
Mike
 
Mike,
Try this

Code:
Dim ListHolder as Dropdownlist=E.Item.FindControl("MyDropDownList")
Dim ValueHolder as String=ListHolder.SelectedItem.Value
Response.write(ValueHolder)

I havent tried it but let me know if throws any errors
Good luck

Note:Copying and Pasting is NoT Creativity.
What would you attempt to accomplish if you knew you would not fail?
 
I have the same problem in dropdown list selected value but not in datagrid. I used the code:

strCity = ddl.selecteditem.value

I passed strCity to another function. It works on and off and took me a lot of time to debug. Finally, I made a text box and code like:(make text box invisible)

txtCity = ddl.selecteditem.value
strCity = txtCity

It works no problem. Why, I do not know.
You can try the same way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top