本文介绍了用户代码未处理空引用异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 帮我查一下错误代码Null引用异常未被用户代码处理 受保护的子lbInsert_Click(ByVal发送者为对象,ByVal e As System.EventArgs ) AccessDataSource1.InsertParameters(Nama)。DefaultValue = DirectCast(GridView1.FooterRow.FindControl(txtNama),TextBox).Text AccessDataSource1.InsertParameters(NpwpPemotong)。DefaultValue = DirectCast(GridView1.FooterRow.FindControl(txtNPWP),TextBox).Text AccessDataSource1.InsertParameters(NomorBukti)。DefaultValue = DirectCast(GridView1.FooterRow.FindControl(txtNomorBukti),TextBox).Text AccessDataSource1.InsertParameters(TglBuktiPemotong)。DefaultValue = DirectCast(GridView1.FooterRow.FindControl(txtTglBukti),Calendar)。 SelectedDate AccessDataSource1.InsertParameters(JenisPajak)。DefaultValue = DirectCast(GridView1.FooterRow.FindControl(ddlInsertJenisPajak),DropDownList).SelectedValue AccessDataSource1.InsertParameters(JumlahPPH)。DefaultValue = DirectCast(GridView1.FooterRow.FindControl(txtJumlahPPH),TextBox) .Text AccessDataSource1.Insert() 结束子 谢谢 我尝试了什么: 空引用异常未被处理用户代码Hi, help me for the error code Null reference exception was unhandled by user codeProtected Sub lbInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs) AccessDataSource1.InsertParameters("Nama").DefaultValue = DirectCast(GridView1.FooterRow.FindControl("txtNama"), TextBox).Text AccessDataSource1.InsertParameters("NpwpPemotong").DefaultValue = DirectCast(GridView1.FooterRow.FindControl("txtNPWP"), TextBox).Text AccessDataSource1.InsertParameters("NomorBukti").DefaultValue = DirectCast(GridView1.FooterRow.FindControl("txtNomorBukti"), TextBox).Text AccessDataSource1.InsertParameters("TglBuktiPemotong").DefaultValue = DirectCast(GridView1.FooterRow.FindControl("txtTglBukti"), Calendar).SelectedDate AccessDataSource1.InsertParameters("JenisPajak").DefaultValue = DirectCast(GridView1.FooterRow.FindControl("ddlInsertJenisPajak"), DropDownList).SelectedValue AccessDataSource1.InsertParameters("JumlahPPH").DefaultValue = DirectCast(GridView1.FooterRow.FindControl("txtJumlahPPH"), TextBox).Text AccessDataSource1.Insert() End SubthanksWhat I have tried:Null reference exception was unhandled by user code推荐答案我认为您在签署价值之前验证是否存在控件...I think that you have validate if exists controls before you asigned value...AccessDataSource1.InsertParameters("Nama").DefaultValue = <pre lang="XML">GridView1.FooterRow.FindControl("txtNama") <> null ?DirectCast(GridView1.FooterRow.FindControl("txtNama"), TextBox).Text</pre> : "" 这篇关于用户代码未处理空引用异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-07 23:31