when click the photos link error!!! RRS feed

  • Question

  • User1008603347 posted

    While web site is running fine when i click the photos link i have an error "Object cannot be cast from DBNull to other types".

    in the page PhotoAlbum_List.aspx  line 11  " pages = Convert.ToInt32(e.Command.Parameters["@pageCount"].Value)"

    How can i fix this??

    Tuesday, February 17, 2009 8:27 AM

All replies

  • User1485238302 posted

    This means that a value of type DBNull is returned (may be because you do not have any photos and the procedure is returning null).

    You can either use Int32.TryParse or check for DBNull before you do this. 

    // TryParse
    int count;
    bool result = Int32.TryParse(e.Command.Parameters["@pageCount"].Value.ToString(), out count);
    pages = count;
    // OR
    if(e.Command.Parameters["@pageCount"].Value != DBNull.Value)
       pages = Convert.Int32(e.Command.Parameters["@pageCount"].Value);
    Tuesday, February 17, 2009 8:57 AM
  • User1008603347 posted

    i tried two way but there is error "Object cannot be cast from DBNull to other types.

    pages = Convert.ToInt32(e.Command.Parameters["@pageCount"].Value);

    how can i add photo  after logging in as administrator?(or Manually) i cant find a menu to add photo ....

    Tuesday, February 17, 2009 9:05 AM
  • User1485238302 posted

    I haven't used Club Site Starter Kit so I can only help with the error. Can you post the code around it, not just the exception statement?

    Tuesday, February 17, 2009 9:36 AM