加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

[VB.NET]请问:怎么获取DATAGRID中的值?

发布时间:2020-12-16 23:40:20 所属栏目:大数据 来源:网络整理
导读:请问:怎么获取DATAGRID中的值? 我想根据DATAGRID中绑定的控件,在ItemDataBound事件中, 判断某控件绑定的数据是否有值,如果没有值的话,则隐藏,显示另一控件. 如果有值,则显示该控件,隐藏其它控件. 我现在的错误是,我所绑定的控件LBLCHN.Text取到的值始终为空

请问:怎么获取DATAGRID中的值?
我想根据DATAGRID中绑定的控件,在ItemDataBound事件中,
判断某控件绑定的数据是否有值,如果没有值的话,则隐藏,显示另一控件.
如果有值,则显示该控件,隐藏其它控件.
我现在的错误是,我所绑定的控件LBLCHN.Text取到的值始终为空,大家帮忙看看哪里有错?

HTML 中的代码如下:


<%# DataBinder.Eval(Container.DataItem,CustomerCHN ) %>


<%# DataBinder.Eval(Container.DataItem,CustomerLM ) %>


<%# DataBinder.Eval(Container.DataItem,CustomerKATA ) %>


<%# DataBinder.Eval(Container.DataItem,CompanyID ) %>




------------------------------------------
VB中的代码如下:
在dg_Master_ItemDataBound事件中

Dim LBLCHN As Label = DirectCast(e.Item.FindControl( LBLCHN ),Label)
Dim LBLLM As Label = DirectCast(e.Item.FindControl( LBLLM ),Label)
Dim LBLKATA As Label = DirectCast(e.Item.FindControl( LBLKATA ),Label)
Dim LBLCP As Label = DirectCast(e.Item.FindControl( LBLCP ),Label)

If Not LBLCHN.Text.ToString.Trim().Equals(String.Empty) Then 顧客氏名(漢字)
e.Item.FindControl( LBLCHN ).Visible = True
e.Item.FindControl( LBLLM ).Visible = False
e.Item.FindControl( LBLKATA ).Visible = False
e.Item.FindControl( LBLCP ).Visible = False
Else
If LBLLM.Text <> Then 顧客氏名(ローマ)
e.Item.FindControl( LBLCHN ).Visible = False
e.Item.FindControl( LBLLM ).Visible = True
e.Item.FindControl( LBLKATA ).Visible = False
e.Item.FindControl( LBLCP ).Visible = False 
         END IF
END IF
__________________________________________________________________________
不好意思,HTML代码发的有点乱,重发一遍


<%# DataBinder.Eval(Container.DataItem,CustomerCHN ) %> <%# DataBinder.Eval(Container.DataItem,CustomerLM ) %> <%# DataBinder.Eval(Container.DataItem,CustomerKATA ) %> <%# DataBinder.Eval(Container.DataItem,CompanyID ) %>
__________________________________________________________________________
都没遇到过吗?是不是不能这样控制啊?
__________________________________________________________________________

<%# DataBinder.Eval(Container.DataItem,CustomerCHN ) %>

----------------------
应该是这样绑定的, > 你其他的Label都绑定错了, __________________________________________________________________________

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读