-
Datagrid question
Here's some code I have. I get the error:
Object reference not set to an instance of object. It happens on the
myitems(0) line. The 'contactid' is a bound column.
If objitem.ItemType = ListItemType.Item Or objitem.ItemType = ListItemType.AlternatingItem Then
myitems(0) = CType(objitem.FindControl("contactid"), Label).Text
myitems(1) = CType(objitem.FindControl("name"), Label).Text
myitems(2) = CType(objitem.FindControl("admin"), Label).Text
myitems(3) = CType(objitem.FindControl("broadcast"), Label).Text
End If
-
Re: Datagrid question
That's beacuse u are looking for a control....ie, the function name is not .FindBoundColumn.
And if it's a column, what makes you think u can convert it to a label.
use...objitem.cells(3) to get data from bound columns.
What I would do however, is not bind to a column, but instead add a label to the column and bind the text property of the label. Then ya code above will wrk,
Woka
-
Re: Datagrid question
I thought about that - if I put a label inside a template column it would work.
-
Re: Datagrid question
Objitem.cells(0) works - but will it also work for a template column? I have to have a mix of template columns and bound columns.
-
Re: Datagrid question
no cell(0) will show as "" if you have a label in it.
I wouldn't use bound columns to be fair. I'd use all template columns. much neater and nicer and more customisable than bound columns.
Woka