Results 1 to 5 of 5

Thread: Datagrid question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2005
    Posts
    625

    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

  2. #2
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    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

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2005
    Posts
    625

    Re: Datagrid question

    I thought about that - if I put a label inside a template column it would work.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2005
    Posts
    625

    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.

  5. #5
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    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
  •  



Click Here to Expand Forum to Full Width