|
-
Apr 25th, 2006, 03:34 PM
#1
Thread Starter
Fanatic Member
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
-
Apr 25th, 2006, 03:38 PM
#2
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
-
Apr 25th, 2006, 03:45 PM
#3
Thread Starter
Fanatic Member
Re: Datagrid question
I thought about that - if I put a label inside a template column it would work.
-
Apr 25th, 2006, 03:48 PM
#4
Thread Starter
Fanatic Member
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.
-
Apr 25th, 2006, 04:27 PM
#5
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|