Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Need help with Datalist Edit Command

Need help with Datalist Edit Command

Scheduled Pinned Locked Moved ASP.NET
helpdata-structuresdebugging
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AdamNThompson
    wrote on last edited by
    #1

    I need a little help with some code I'm working on. I have a Datalist control that is throwing the following expeption. ------------------------------------------------------------------------ Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. ------------------------------------------------------------------------ Here is my code. Sub Edit_Command(ByVal sender As Object, ByVal e As DataListCommandEventArgs) Handles DataList.EditCommand DataList.EditItemIndex = CType(e.Item.ItemIndex, Integer) Dim strDate As String = "" Dim strAssignments As String = "" Dim strSchool As String = "" Dim strProgramme As String = "" Dim strSubject As String = "" Dim strCity As String = "" Dim strState As String = "" Dim strReason As String = "" Dim reader As SqlDataReader Dim cmd As New SqlCommand("SELECT * FROM tblVolDeclinedMissedCanceledAssignments WHERE VolunteerId=" & VolunteerId() & " AND Id=" & e.CommandArgument, cn) cmd.CommandType = Data.CommandType.Text Try cn.Open() reader = cmd.ExecuteReader() While reader.Read strDate = IIf(IsDBNull(reader("Date")), "", reader("Date")) strAssignments = IIf(IsDBNull(reader("Assignment")), "", reader("Assignment")) strSchool = IIf(IsDBNull(reader("SchoolVenue")), "", reader("SchoolVenue")) strProgramme = IIf(IsDBNull(reader("Programme")), "", reader("Programme")) strSubject = IIf(IsDBNull(reader("Subject")), "", reader("Subject")) strCity = IIf(IsDBNull(reader("City")), "", reader("City")) strState = IIf(IsDBNull(reader("StateProvince")), "", reader("StateProvince")) strReason = IIf(IsDBNull(reader("Reason")), "", reader("Reason")) End While Catch ex As Exception Throw New ApplicationException(ex.Message) Finally cn.Close() End Try CType(e.Item.FindControl("rdpEditDate"), Telerik.WebControls.RadDatePicker).SelectedDate = strDate CType(e.Item.FindControl("ddlEditAssignments

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups