thegunner
thegunner

Reputation: 7153

datarow item in repeater doesn't exist

I'm going through a repeater databound sub.

The data in the repeater can depend on what is selected in a dropdown, but some of my sql that is being used to display the data doesn't have a column price - how can I say e.g. "if exists "price" e.g.

I was trying:

If Not CType(e.Item.DataItem, DataRowView) Is DBNull.Value Then
    'Do this
end if

Any ideas?

Upvotes: 0

Views: 190

Answers (1)

Tim Schmelter
Tim Schmelter

Reputation: 460058

DataItem is always nothing/null on postbacks, it's only set after databinding. Values are maintained in ViewState(by default) across postbacks, so there's no need to maintain the datasource.

So you should use e.Item.FindControls(controlID) instead.

Upvotes: 2

Related Questions