asp.net - Help: Error = NullReferenceException was unhandled by user code -
any appreciated... code works cleanly until error...
error occuring @ line: sqldatasource3.updateparameters("techid").defaultvalue() = cint(technicianrow("techid"))
here full vb code:
imports system.data partial class incidentassignment inherits system.web.ui.page public incidentrow datarowview public technicianrow datarowview protected sub button1_click(byval sender object, byval e system.eventargs) handles button1.click 'check see if incident has been selected if gridview1.selectedindex = -1 button1.commandname = "" lblmessage.text = "you must select incident." else button1.commandname = "nextview" lblmessage.text = "" end if end sub protected sub button3_click(byval sender object, byval e system.eventargs) handles button3.click 'check see if incident has been selected if gridview2.selectedindex = -1 button3.commandname = "" lblmessage2.text = "you must select technician." else button3.commandname = "nextview" lblmessage2.text = "" 'create second dataview dim technicianstable dataview = ctype(sqldatasource2.select(datasourceselectarguments.empty), dataview) 'save selected technician data row 'to datarowview object , session state technicianrow = technicianstable(gridview2.selectedindex) session("technician") = technicianrow 'create dataview dim incidentstable dataview = ctype(sqldatasource1.select(datasourceselectarguments.empty), dataview) 'save pageindex , pagesize variables. dim pageindex integer = gridview1.pageindex dim pagesize integer = gridview1.pagesize 'calculate value of selectedindex dim selectedindex integer = (pageindex * pagesize) + gridview1.selectedindex 'save selected data row datarowview 'object , session state incidentrow = incidentstable(selectedindex) session("incident") = incidentrow 'display output 2 datarowview objects label1.text = incidentrow("name") label2.text = incidentrow("productcode") label3.text = technicianrow("name") end if end sub public sub btnassign_click(byval sender object, byval e system.eventargs) handles btnassign.click 'assign data session state 'the 2 datarowview objects ***error technicianrow = ctype(session("technician"), datarowview) incidentrow = ctype(session("incident"), datarowview) 'update value of 2 parameters 'used store new information 'assigned technician sqldatasource3.updateparameters("techid").defaultvalue() = cint(technicianrow("techid")) sqldatasource3.updateparameters("incidentid").defaultvalue() = cint(incidentrow("incidentid")) 'trap errors try 'update table. sqldatasource3.update() 'unselect 2 gridview controls gridview1.selectedindex = -1 gridview2.selectedindex = -1 'rebind gridview controls gridview1.databind() gridview2.databind() 'move first view multiview1.activeviewindex = 0 catch ex exception session("exception") = ex session("page") = "~/admin/indicentassignment.aspx" response.redirect("~/errormessage.aspx") end try end sub protected sub gridview2_selectedindexchanged(byval sender object, byval e system.eventargs) handles gridview2.selectedindexchanged end sub end class
remove parenthesis ".defaultvalue()
do have parameters defined on sqldatasource in page??
updateparameters> <asp:parameter name="somename" type="string" /> <asp:parameter name="somedescription" type="string" /> </updateparameters>
Comments
Post a Comment