如何找到列表视图控件 [英] How to find list view control

查看:63
本文介绍了如何找到列表视图控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我必须在单击按钮时编辑列表视图,然后再进行更新.
我的代码生成一个错误....对象引用未设置为对象的实例."
我的代码如下.....

收合|复制代码

 受保护的  Sub  btnedit_Click( ByVal 发​​件人 As  对象 ByVal  e  As  System.EventArgs) Handles  btnedit.Click
 Dim  currentID  As  整数
         Dim  dblAmount1  As  整数
         Dim  dblAmount2  As  整数
   Dim  myAdapter  As  spGetFeeStructureTableAdapter
对于 每个项目 As  ListViewDataItem 位于 lvFeeStructure.Items中
           currentID = lvFeeStructure.DataKeys(item.DataItemIndex).Value
           intGradeID =  CType (ddlGrades.SelectedValue,整数)
           如果(item.ItemType = ListViewItemType.DataItem)然后
           dblAmount1 = Val( CType (item.FindControl " ),TextBox).Text)
                dblAmount2 = Val( CType (item.FindControl(" ),TextBox).Text)
myAdapter.UpdateFeeStructure(" ,intGradeID,dblAmount1,dblAmount2)
lvFeeStructure.DataBind()
 
结束  



请帮帮我.


谢谢
Pooja Thakur

解决方案

您需要做的就是在代码块的开头放置一个断点,然后使用Visual Studio进行调试.逐行逐步执行代码,直到其中断为止,此时您将找到要引用的对象,该对象为null.在使用该对象之前,对它添加!= null检查,或确保对其进行了初始化并拥有解决方案.


hi
I''ve to edit listview on button click and then update too.
my code generating an error...."Object reference not set to an instance of an object."
my code is as follows.....

Collapse | Copy Code

Protected Sub btnedit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnedit.Click
Dim currentID As Integer
        Dim dblAmount1 As Integer
        Dim dblAmount2 As Integer
  Dim myAdapter As spGetFeeStructureTableAdapter
For Each item As ListViewDataItem In lvFeeStructure.Items
           currentID = lvFeeStructure.DataKeys(item.DataItemIndex).Value
           intGradeID = CType(ddlGrades.SelectedValue, Integer)
           If (item.ItemType = ListViewItemType.DataItem) Then
           dblAmount1 = Val(CType(item.FindControl "decMonth1TextBox"), TextBox).Text)
                dblAmount2 = Val(CType(item.FindControl("decMonth2TextBox "), TextBox).Text)
myAdapter.UpdateFeeStructure("CurrentID", intGradeID,dblAmount1 ,dblAmount2)
lvFeeStructure.DataBind()
 
End Sub



Please help me out.


Thank You
Pooja Thakur

解决方案

All you need to do is place a breakpoint at the beginning of the code block and debug using your Visual Studio. Step through the code line by line until it breaks at which point you will find the object you are referencing which is null. Add a != null check on that object before you use it, or guarantee that it is initialized and you have your solution.


这篇关于如何找到列表视图控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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