views:

39

answers:

2

Hello,

I have to maintain an ASP.net application in VB.Net. There is a page with a FormView bound to a ObjectDataSource.

I have to add some business logic on the ItemUpdating event of this FormView.

Unfortunately, some the data that I need to add this business logic is not exposed on the FormView user-interface itself, so I can not use FindControl to get the values (I could add the controls, bind them to the fields I need and set their visible property to true, but that's ugly).

So, what I would need to do is to get access to the Data Row corresponding to the currently selected item in the FormView from the code behind as it has the data I need to add my business logic code.

Unfortunately, I don't manage to get access to the row.

Thanks in advance for your help.

+1  A: 

Try this:

Dim myData As Object = DirectCast(formview1.DataItem, DataRowView)("MyColumn")

EDIT: If I remember correctly the DataItem is Nothing on ItemUpdating so my solution above does not work, does it? Then you have to load it from your Datasource with the given ID(CommandArgument).

Tim Schmelter
A: 

Thanks, I managed to sort it using the Select method of the ObjectDataSource object. This returned me a DataView containing the row that was currently being edited.

Kharlos Dominguez