用户代码未处理空引用异常 [英] Null reference exception was unhandled by user code

查看:88
本文介绍了用户代码未处理空引用异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

帮我查一下错误代码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 < br $>


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 code

Protected 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 Sub


thanks

What 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(&quot;txtNama&quot;) <> null ?
DirectCast(GridView1.FooterRow.FindControl(&quot;txtNama&quot;), TextBox).Text</pre> : ""


这篇关于用户代码未处理空引用异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆