troubleshooting Question

Show/Hide DetailsView Rows in Insert, Edit

Avatar of codequest
codequest asked on
ASP.NET
2 Comments1 Solution606 ViewsLast Modified:
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>
========================
ASKER CERTIFIED SOLUTION
BooMod

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros