在隐藏/取消隐藏标题文本方面需要帮助 [英] Need help with hide/unhide Headertext

查看:75
本文介绍了在隐藏/取消隐藏标题文本方面需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有标题文本列表的DetailsView. PERM CODE标题文本是隐藏的,并且仅在选择的DROPDOWN选项为DETAIL时才显示.

这是我的aspx和vb代码,后面的代码不起作用.
ASPX代码:

I have a DetailsView with a list of Headertext. The PERM CODE headertext is hidden and will only be displayed when the DROPDOWN option choosen is DETAIL.

Here is my aspx and vb code behind which is not working.
ASPX code:

<asp:TemplateField HeaderText = "DATAITEM:">
    <itemtemplate>
      <asp:Label ID="LblDataItem" runat="server" 

               Text= '<%# eval("dataitem") %>' />
    </itemtemplate>
    <edititemtemplate>
       <asp:DropDownList ID="DDLDataItemnew" runat="server"

          AutoPostBack ="true"

         OnSelectedIndexChanged = "DDLDataItemnew_selectedindexchanged"

        >
         <asp:ListItem>Choose One
         <asp:ListItem>DETAIL
         <asp:ListItem>SUMMARY
         <asp:ListItem>CUSTOM         
       </edititemtemplate>
<asp:TemplateField HeaderText = "PERM CODE:" Visible="false" >
    <edititemtemplate>
        <asp:DropDownList ID="DDLPermCode" runat="server"  />
        </edititemtemplate>


后面的VB代码


VB code behind

Protected Sub DDLDataItemnew_selectedindexchanged(ByVal sender As Object, ByVal e As EventArgs)
    Dim tmp_dataitem As DropDownList = DirectCast(DTLVwAddeduser.FindControl("DDLDataItemnew"), DropDownList)
        Dim dataitem As String = Trim(tmp_dataitem.Text)
        If dataitem = "DETAIL" Then
            If DTLVwAddeduser.CurrentMode = DetailsViewMode.Edit Then
                //get the index of the DATAITEM headertext
                Dim i As Integer = GetIndex("DATAITEM:",DTLVwAddeduser) 
                DTLVwAddeduser.Fields(i).Visible = True
            End If
        End If
End Sub


推荐答案



试试这个

Dim dataitem As String = Trim(tmp_dataitem.SelectedItem.Value)

代替
Dim dataitem As String = Trim(tmp_dataitem.Text)
Hi,

Try this

Dim dataitem As String = Trim(tmp_dataitem.SelectedItem.Value)

Instead of
Dim dataitem As String = Trim(tmp_dataitem.Text)


这篇关于在隐藏/取消隐藏标题文本方面需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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