DataGrid - DropDownList Binding!

A

Adam Knight

Hi all,

I am trying to preselect a value in a dropdown list contained in a DataGrid
via the 'SelectedValue' method.
I tried using Container.DataItem in the DataGrid onItemDataBound method and
an error was issued.
'Container not declared'.

Can anyone suggest how i am supposed to retrieve the require db value.

'ensure current data grid row is not a header or footer, not a category and
is being edited
If(e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <>
ListItemType.Footer And e.Item.ItemIndex = dgMyGrid.EditItemIndex)

'preselect db value in drop down list
CType(e.Item.Cells(1).Controls(1),DropDownList).SelectedValue =
Container.DataItem("optional_questions")

End If

Cheers,
Adam
 

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,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top