Avatar of codequest
codequest
 asked on

Show/Hide DetailsView Rows in Insert, Edit

The code here will show/hide DetailsView rows in ReadOnly mode.  I'm looking for technique to do the same for Insert and Edit modes.  

Any help on this would be appreciated.

Thanks!
========================
      Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Select Case Me.TextBox1.Text
                  Case "A"
                        Me.DetailsView1.Rows(2).Visible = False
                        Me.DetailsView1.Rows(3).Visible = False
                        Me.DetailsView1.Rows(4).Visible = True
                        Me.DetailsView1.Rows(5).Visible = True
                  Case "B"
                        Me.DetailsView1.Rows(2).Visible = True
                        Me.DetailsView1.Rows(3).Visible = True
                        Me.DetailsView1.Rows(4).Visible = False
                        Me.DetailsView1.Rows(5).Visible = False
            End Select

========================
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Details.aspx.vb" Inherits="NewFolder1_Details" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
                  InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
                  TypeName="DataSet1TableAdapters.DBTable1TableAdapter" UpdateMethod="Update" DeleteMethod="Delete">
                  <InsertParameters>
                        <asp:Parameter Name="Field1" Type="String" />
                        <asp:Parameter Name="Field2" Type="String" />
                        <asp:Parameter Name="Field3" Type="String" />
                        <asp:Parameter Name="Field4" Type="String" />
                        <asp:Parameter Name="Field5" Type="String" />
                  </InsertParameters>
                  <DeleteParameters>
                        <asp:Parameter Name="Original_ID" Type="Int32" />
                  </DeleteParameters>
                  <UpdateParameters>
                        <asp:Parameter Name="Field1" Type="String" />
                        <asp:Parameter Name="Field2" Type="String" />
                        <asp:Parameter Name="Field3" Type="String" />
                        <asp:Parameter Name="Field4" Type="String" />
                        <asp:Parameter Name="Field5" Type="String" />
                        <asp:Parameter Name="Original_ID" Type="Int32" />
                        <asp:Parameter Name="ID" Type="Int32" />
                  </UpdateParameters>
            </asp:ObjectDataSource>
            <asp:TextBox ID="TextBox1" runat="server" Style="position: relative" Width="120px"></asp:TextBox>
            <asp:Button ID="Button1" runat="server" Style="position: relative" Text="Button" /></div>
            <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="ObjectDataSource1"
                  Height="50px" Width="125px" DataKeyNames="ID">
                  <Fields>
                        <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                              SortExpression="ID" />
                        <asp:BoundField DataField="Field1" HeaderText="Field1" SortExpression="Field1" />
                        <asp:BoundField DataField="Field2" HeaderText="Field2" SortExpression="Field2" />
                        <asp:BoundField DataField="Field3" HeaderText="Field3" SortExpression="Field3" />
                        <asp:BoundField DataField="Field4" HeaderText="Field4" SortExpression="Field4" />
                        <asp:BoundField DataField="Field5" HeaderText="Field5" SortExpression="Field5" />
                        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
                  </Fields>
            </asp:DetailsView>
    </form>
</body>
</html>
========================
ASP.NET

Avatar of undefined
Last Comment
BooMod

8/22/2022 - Mon
codequest

ASKER
ASKER CERTIFIED SOLUTION
BooMod

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Your help has saved me hundreds of hours of internet surfing.
fblack61