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

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top