Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
XML
<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 code behind
VB
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

Can someone please assist?
Posted
Updated 12-Oct-10 9:36am
v2
Comments
Sandeep Mewara 12-Oct-10 15:37pm    
PRE tags make your question readable. Use it.

1 solution

Hi,

Try this

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

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900