Capturing an event within a template column

S

sqlboy2000

All,
I have a simple datagrid with one column being a template column that
contains a dropdown control. I'd like to be able capture when the
index of the dropdown changes and access the value that has been
selected. I've tried the datagrid's itemcommand event but it doesn't
fire when the dropdown selection changes. Here is the closest solution
I could come up with using the onchange event:

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal
e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound

If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim oDD As DropDownList = e.Item.FindControl("cboChoose")
oDD.Attributes.Add("onchange", "alert('" &
oDD.SelectedItem.Text & "');")
End If


End Sub

The only problem is, the SelectedItem.text value in the "alert" is
being generated as each column is bound, so it's always returning the
initial value. Anyone have any ideas on how to properly manage a
dropdown changed event within a template column? This seems like it
shouldn't be difficult, but several google searches have yielded
nothing.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top