locked
DataRowView in a Repeater RRS feed

  • Question

  • User-1208031168 posted

    Dim nonserials As Publications.NonSerialPubsRow = CType(CType(e.Item.DataItem, System.Data.DataRowView).Row, Publications.NonSerialPubsRow)

    with the above line within the repeater's ItemDatabound event throws the following error.

    Unable to cast object of type 'NonSerialPubsRow' to type
    'System.Data.DataRowView'.

    I am binding the repeater with an object datasource.

    Many thanks for your kind help.

    Monday, August 15, 2011 9:15 AM

Answers

  • User3866881 posted

    Plz make sure that your codes must be in this block:

    void R1_ItemDataBound(Object Sender, RepeaterItemEventArgs e) {

              if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
              {
                      //Put your codes here....
                       Dim nonserials As Publications.NonSerialPubsRow = CType(CType(e.Item.DataItem, System.Data.DataRowView).Row, Publications.NonSerialPubsRow)
              }
           }   

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 16, 2011 10:49 PM