Dropdowlist in a gridview in edit mode

L

Lupakkiotto

Hi!, I am using framework 2.0 and Visual Visual Web Developer Express.
In a gridview, when it is in editmode, I have a dropdownlist in a
templatefield. The problem is that it show always the first item in the list
and not the current one correspondin to the value saved in the database....
How can I solve the problem? I have read about the event itemdatabound of
the gridview, but if I try the code below:

Sub GridView1_ItemDataBound(ByVal Sender As Object, ByVal e As
DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.EditItem Then
Dim ddl As DropDownList
ddl = CType(e.Item.FindControl("comboTipoIndennita"), DropDownList)
ddl.SelectedIndex =
ddl.Items.IndexOf(ddl.Items.FindByText(DataBinder.Eval(e.Item.DataItem,
"comboTipoIndennita")))
End If
End Sub

it says me that the gridview can't handles that event...
Thanks in advance and sorry for my english...
Marco
 

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

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top