Dim i As Integer = GetFieldIndexByHeaderText("DATAITEM:",
DTLVwAddeduser)
I have a DetailsView with a list of Headertext.
 Headertext PERM CODE is hidden and should only be displayed when
"DETAIL" is chosen in the DROPDOWNLIST.

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


Can someone please assist?

Reply via email to