Link to home
Start Free TrialLog in
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>
========================
Avatar of codequest
codequest

ASKER

ASKER CERTIFIED SOLUTION
Avatar of BooMod
BooMod
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial