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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top