Databinding if column exists or not

R

ree32

I keep getting this error
colName1 is neither a DataColumn nor a DataRelation for table
tablename1

When I am trying to check for a value

Sub databoundVersion(ByVal s As Object, ByVal e As
RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType =
ListItemType.Item Then
If Not e.Item.DataItem("colName1 ") Is Nothing Then '<===
error line
If Not e.Item.DataItem("colName1 ") Is DBNull.Value
Then
If e.Item.DataItem("colName1 ") = "True" Then

End If
End If
End If


I need a way to check if the column exists while databinding. See
sometimes the columns don't exist because the data is taken from an xml
file and converted to a dataset then databound to a repeater.
 
E

Eliyahu Goldin

(e.Item.DataItem as DataRowView).Row.Table.Columns.Contains("colName1")

Eliyahu
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top