Solved

ASP .NET Details view insert with Parent Key

Posted on 2009-04-07
8
1,148 Views
Last Modified: 2013-11-26
I have an asp .net app that uses a DetailView to show a single record along with a gridview showing related update comments (that are in a one to many relationship with the selected Detail record).  The Detail View record and the Comments in the grid are linked by a field called "MasterRecordID".  One detail record may have several associated "comments" which are shown in the gridview.  

The user needs the ability to add comments associated with the selected Detail record and I know that I cannot just do an insert to the "comments" gridview.  I am trying to use an "Add Comment" button that opens a blank detail view of the Comments in Insert mode.  There are only 3 fields in this Comments Detail View (MasterRecordID, Date and Comment).

The problem that I have is that the insert Comment detail view opens with all 3 fields blank.  I need the MasterRecordID to pre-populate from the selected MasterRecordID so the user doesn't have to type that field in.  I have searched the web and found descriptions of custom selection and insert routines which store and use the value of the selected ID.  I would think that I need to somehow store the DetailView MasterRecordID value and then use it to populate the MasterRecordID field of the new comment record, but can't quite get there.

Sorry for the long-winded question...thanks in advance.
Sophig
0
Comment
Question by:SophiG
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24101424
"I am trying to use an "Add Comment" button that opens a blank detail view of the Comments in Insert mode"

Can you explain what you mean by "Add Comment" button in more detail?
0
 

Author Comment

by:SophiG
ID: 24103632
I have a page with a detail view of "Service Calls".  The Detail view shows the following:
MasterRecordID (key)
Date (of Service Call)
Location (of Call)
UserName (who entered the Call)
Description (of problem)
Open\Closed
Date Closed (if call is complete)

The Person Servicing the call needs to be able to put in "update comments" regarding the service call.  So, for each call there may be daily updates about work progress, parts ordered or received, etc.  There may be many update comments for each service call and these are related to the master Service Call record by the MasterRecordID.  If an update comment needs to be added, the user clicks on the "Add Comment" Button on the page and a new blank insert record for the new comment becomes visible.  This part I have working fine.  The fields that appear in the insert record include:
MasterRecordID (to relate it to the Service Call)
CommentID (key)
Date (of comment)
Comment (text)

All of the above works fine...
Since the comment input fields are being displayed on the same page under the detail of the Service Call, I want the MasterRecordID of the service call to populate automatically in the new Comment insertion form.

Let me know if I need to attach any code, etc.  Thanks!
Sophig
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24106915
Confessions of an E-E addict:  I spend a lot of time reading through words (not my speciality), to try to find meaning, and then go round and round asking questions, proposing possible solutions...

I am always trying to find a "better way" of looking over your shoulder, to see what the words mean.  Sometimes I find that a screen shot is worth 10000 words.  Let's start with attaching any .png screen shot that you think might explain what you mean...
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:SophiG
ID: 24107408
LearnedOne,

Here's the whole story in pictures and code...it's not pretty, but it's whats working so far.

Thanks again.
<%@ Page Language="VB" MasterPageFile="~/CMMaster.master" AutoEventWireup="false" CodeFile="EditRequests.aspx.vb" Inherits="EditInsertDelete_Basics" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
        SelectMethod="GetRecordSummary" TypeName="RequestsTableAdapters.tblService_RecordsTableAdapter"
        UpdateMethod="Update" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}">
        <DeleteParameters>
            <asp:Parameter Name="Original_ServiceRecordID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="DateEntered" Type="DateTime" />
            <asp:Parameter Name="LaborHours" Type="Single" />
            <asp:Parameter Name="NumberPeople" Type="Int32" />
            <asp:Parameter Name="Priority" Type="Int32" />
            <asp:Parameter Name="BldgNumber" Type="Int32" />
            <asp:Parameter Name="ExactLocation" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="DateCompleted" Type="DateTime" />
            <asp:Parameter Name="Closed" Type="Boolean" />
            <asp:Parameter Name="FName" Type="String" />
            <asp:Parameter Name="LName" Type="String" />
            <asp:Parameter Name="Original_ServiceRecordID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="DateEntered" Type="DateTime" />
            <asp:Parameter Name="LaborHours" Type="Single" />
            <asp:Parameter Name="NumberPeople" Type="Int32" />
            <asp:Parameter Name="Priority" Type="Int32" />
            <asp:Parameter Name="BldgNumber" Type="Int32" />
            <asp:Parameter Name="ExactLocation" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="DateCompleted" Type="DateTime" />
            <asp:Parameter Name="Closed" Type="Boolean" />
            <asp:Parameter Name="FName" Type="String" />
            <asp:Parameter Name="LName" Type="String" />
        </InsertParameters>
    </asp:ObjectDataSource>
    &nbsp; &nbsp; &nbsp;
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" DataKeyNames="ServiceRecordID" DataSourceID="ObjectDataSource1" >
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" >
                <ControlStyle Font-Size="Small" />
            </asp:CommandField>
            <asp:BoundField DataField="ServiceRecordID" HeaderText="ID" InsertVisible="False"
                ReadOnly="True" SortExpression="ServiceRecordID" >
                <ItemStyle Font-Size="X-Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" BackColor="Silver" />
            </asp:BoundField>
            <asp:TemplateField HeaderText="Date Entered" SortExpression="DateEntered">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("DateEntered") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemStyle Font-Size="X-Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" BackColor="Silver" />
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("DateEntered", "{0:d}") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="LaborHours" HeaderText="# Hours" SortExpression="LaborHours" >
                <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" BackColor="Silver" />
            </asp:BoundField>
            <asp:BoundField DataField="NumberPeople" HeaderText="# People" SortExpression="NumberPeople" >
                <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" BackColor="Silver" />
            </asp:BoundField>
            <asp:BoundField DataField="Priority" HeaderText="Priority" SortExpression="Priority" >
                <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" BackColor="Silver" />
            </asp:BoundField>
            <asp:BoundField DataField="BldgNumber" HeaderText="Bldg #" SortExpression="BldgNumber" >
                <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" BackColor="Silver" />
            </asp:BoundField>
            <asp:BoundField DataField="ExactLocation" HeaderText="Exact Location" SortExpression="ExactLocation" >
                <ItemStyle Font-Size="X-Small" HorizontalAlign="Left" />
                <HeaderStyle Font-Size="Small" BackColor="Silver" />
            </asp:BoundField>
            <asp:TemplateField HeaderText="Description" SortExpression="Description">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                </EditItemTemplate>
                <HeaderStyle Font-Size="Small" BackColor="Silver" />
                <ItemTemplate>
                    <asp:TextBox ID="TextBox4" runat="server" Font-Size="X-Small" Height="40px" Text='<%# Bind("Description") %>'
                        Width="244px"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Date Complete" SortExpression="Date Complete">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("DateCompleted") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemStyle Font-Size="Small" />
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("DateCompleted", "{0:d}") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle Font-Size="Small" BackColor="Silver" />
            </asp:TemplateField>
            <asp:CheckBoxField DataField="Closed" HeaderText="Closed" SortExpression="Closed" >
                <ItemStyle HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" BackColor="Silver" />
            </asp:CheckBoxField>
            <asp:BoundField DataField="FName" HeaderText="First Name" SortExpression="FName" >
                <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" BackColor="Silver" />
            </asp:BoundField>
            <asp:BoundField DataField="LName" HeaderText="Last Name" SortExpression="LName" >
                <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" BackColor="Silver" />
            </asp:BoundField>
        </Columns>
    </asp:GridView>
    <asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
        SelectMethod="GetDataBy" TypeName="Requests_W_UpdatesTableAdapters.RecordswUpdatesTableTableAdapter">
        <SelectParameters>
            <asp:ControlParameter ControlID="GridView1" Name="ServiceRecordID" PropertyName="SelectedValue"
                Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <br />
    <asp:Label ID="Label3" runat="server" Font-Size="Large" ForeColor="Navy" Text="Detail View of Selected Record:" Visible="False"></asp:Label><br />
    <asp:DetailsView ID="RecordDetails" runat="server" AutoGenerateRows="False"
        DataSourceID="ObjectDataSource2" Height="50px" Width="192px">
        <Fields>
            <asp:BoundField DataField="ServiceRecordID" HeaderText="ID" InsertVisible="False"
                SortExpression="ServiceRecordID" >
                <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" HorizontalAlign="Right" Font-Bold="True" ForeColor="Blue" BackColor="Silver" />
            </asp:BoundField>
            <asp:TemplateField HeaderText="Date Entered" SortExpression="DateEntered">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("DateEntered") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("DateEntered") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("DateEntered", "{0:d}") %>' Font-Size="Small"></asp:Label>
                </ItemTemplate>
                <HeaderStyle Font-Size="Small" HorizontalAlign="Right" Font-Bold="True" ForeColor="Blue" BackColor="Silver" />
            </asp:TemplateField>
            <asp:BoundField DataField="LaborHours" HeaderText="Labor Hours" SortExpression="LaborHours" >
                <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" HorizontalAlign="Right" Font-Bold="True" ForeColor="Blue" BackColor="Silver" />
            </asp:BoundField>
            <asp:BoundField DataField="NumberPeople" HeaderText="# People" SortExpression="NumberPeople" >
                <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" HorizontalAlign="Right" Font-Bold="True" ForeColor="Blue" BackColor="Silver" />
            </asp:BoundField>
            <asp:BoundField DataField="Priority" HeaderText="Priority" SortExpression="Priority" >
                <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" HorizontalAlign="Right" Font-Bold="True" ForeColor="Blue" BackColor="Silver" />
            </asp:BoundField>
            <asp:BoundField DataField="BldgNumber" HeaderText="Bldg #" SortExpression="BldgNumber" >
                <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" HorizontalAlign="Right" Font-Bold="True" ForeColor="Blue" BackColor="Silver" />
            </asp:BoundField>
            <asp:TemplateField HeaderText="Exact Location" SortExpression="ExactLocation">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("ExactLocation") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("ExactLocation") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemStyle Font-Size="Small" HorizontalAlign="Left" />
                <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Right" ForeColor="Blue" BackColor="Silver" />
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("ExactLocation") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Description" SortExpression="Description">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemStyle Font-Size="Small" HorizontalAlign="Left" />
                <HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Right" ForeColor="Blue" BackColor="Silver" />
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Font-Size="Small" Text='<%# Bind("Description") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Date Complete" SortExpression="DateCompleted">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("DateCompleted") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("DateCompleted") %>'></asp:TextBox>
                </InsertItemTemplate>
                <HeaderStyle Font-Size="Small" HorizontalAlign="Right" Font-Bold="True" ForeColor="Blue" BackColor="Silver" />
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("DateCompleted", "{0:d}") %>' Font-Size="Small"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CheckBoxField DataField="Closed" HeaderText="Closed" SortExpression="Closed" >
                <HeaderStyle Font-Size="Small" HorizontalAlign="Right" Font-Bold="True" ForeColor="Blue" BackColor="Silver" />
                <ItemStyle HorizontalAlign="Center" />
            </asp:CheckBoxField>
            <asp:BoundField DataField="U_Date" HeaderText="U_Date" SortExpression="U_Date" Visible="False" >
                <HeaderStyle BackColor="Silver" />
            </asp:BoundField>
            <asp:BoundField DataField="Updates" HeaderText="Updates" SortExpression="Updates" Visible="False" >
                <HeaderStyle BackColor="Silver" />
            </asp:BoundField>
            <asp:BoundField DataField="FName" HeaderText="First Name" SortExpression="FName" >
                <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" HorizontalAlign="Right" Font-Bold="True" ForeColor="Blue" BackColor="Silver" />
            </asp:BoundField>
            <asp:BoundField DataField="LName" HeaderText="Last Name" SortExpression="LName" >
                <ItemStyle Font-Size="Small" HorizontalAlign="Center" />
                <HeaderStyle Font-Size="Small" HorizontalAlign="Right" Font-Bold="True" ForeColor="Blue" BackColor="Silver" />
            </asp:BoundField>
        </Fields>
    </asp:DetailsView>
    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
        DataSourceID="ObjectDataSource3" AllowSorting="True">
        <Columns>
            <asp:CommandField ShowEditButton="True" ShowDeleteButton="True" >
                <ItemStyle Font-Size="Small" />
                <HeaderStyle ForeColor="Blue" />
            </asp:CommandField>
            <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                SortExpression="ID" >
                <ItemStyle Font-Size="X-Small" />
                <HeaderStyle Font-Size="X-Small" ForeColor="Blue" BackColor="Silver" />
            </asp:BoundField>
            <asp:BoundField DataField="ServiceRecordID" HeaderText="SRID" SortExpression="ServiceRecordID" >
                <ItemStyle Font-Size="X-Small" />
                <HeaderStyle Font-Size="X-Small" ForeColor="Blue" BackColor="Silver" />
            </asp:BoundField>
            <asp:TemplateField HeaderText="Date" SortExpression="U_Date">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("U_Date") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemStyle Font-Size="Small" HorizontalAlign="Left" />
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("U_Date", "{0:d}") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle Font-Size="Small" ForeColor="Blue" BackColor="Silver" />
            </asp:TemplateField>
            <asp:BoundField DataField="Updates" HeaderText="Update Comments" SortExpression="Updates" >
                <ItemStyle Font-Size="Small" HorizontalAlign="Left" />
                <HeaderStyle Font-Bold="True" Font-Size="Small" ForeColor="Blue" BackColor="Silver" />
            </asp:BoundField>
        </Columns>
    </asp:GridView>
    &nbsp;
    <asp:Button ID="Button1" runat="server" Text="Insert Update Comment" Visible="False" />
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="Custom_Code"
        DataSourceID="ObjectDataSource4" DefaultMode="Insert" Height="50px"
        Width="292px" EnablePagingCallbacks="True" Visible="False">
        <Fields>
            <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                SortExpression="ID" >
                <ItemStyle Font-Size="X-Small" />
                <HeaderStyle Font-Size="Smaller" />
            </asp:BoundField>
            <asp:BoundField DataField="ServiceRecordID" HeaderText="SRID" SortExpression="ServiceRecordID" >
                <ItemStyle Font-Size="X-Small" />
            </asp:BoundField>
            <asp:TemplateField HeaderText="Date" SortExpression="U_Date">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("U_Date") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("U_Date") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemStyle Font-Size="X-Small" />
                <HeaderStyle Font-Size="Smaller" />
                <ItemTemplate>
                    <asp:TextBox ID="TextBox5" runat="server" OnDataBinding="GridView1_SelectedIndexChanged"
                        Text='<%# Eval("U_Date", "{0:d}") %>' OnLoad="Button1_Click"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Updates" HeaderText="Update" SortExpression="Updates" >
                <ItemStyle Font-Size="X-Small" />
                <HeaderStyle Font-Size="Smaller" />
            </asp:BoundField>
            <asp:CommandField ShowInsertButton="True" >
                <ItemStyle Font-Size="Small" />
            </asp:CommandField>
        </Fields>
    </asp:DetailsView>
    &nbsp;
    <asp:ObjectDataSource ID="ObjectDataSource4" runat="server" DeleteMethod="Delete"
        InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetDataBy"
        TypeName="DataSet1TableAdapters.tblUpdatesTableAdapter" UpdateMethod="Update">
        <DeleteParameters>
            <asp:Parameter Name="Original_ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="ServiceRecordID" Type="Int32" />
            <asp:Parameter Name="U_Date" Type="DateTime" />
            <asp:Parameter Name="Updates" Type="String" />
            <asp:Parameter Name="Original_ID" Type="Int32" />
        </UpdateParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="RecordDetails" Name="ServiceRecordID" PropertyName="SelectedValue"
                Type="Int32" DefaultValue="GridView1.DataKeys[GridView1.SelectedIndex]" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="ServiceRecordID" Type="Int32" />
            <asp:Parameter Name="U_Date" Type="DateTime" />
            <asp:Parameter Name="Updates" Type="String" />
        </InsertParameters>
    </asp:ObjectDataSource>
    &nbsp; &nbsp;
    <asp:ObjectDataSource ID="ObjectDataSource3" runat="server" DeleteMethod="Delete"
        InsertMethod="Insert" SelectMethod="GetDataBy"
        TypeName="DataSet1TableAdapters.tblUpdatesTableAdapter" UpdateMethod="Update" OldValuesParameterFormatString="original_{0}">
        <DeleteParameters>
            <asp:Parameter Name="Original_ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="ServiceRecordID" Type="Int32" />
            <asp:Parameter Name="U_Date" Type="DateTime" />
            <asp:Parameter Name="Updates" Type="String" />
            <asp:Parameter Name="Original_ID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="ServiceRecordID" Type="Int32" />
            <asp:Parameter Name="U_Date" Type="DateTime" />
            <asp:Parameter Name="Updates" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="GridView1" Name="ServiceRecordID" PropertyName="SelectedValue"
                Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>
</asp:Content>
 
 
Code Behind:
 
Partial Class EditInsertDelete_Basics
    Inherits System.Web.UI.Page
 
    Protected Sub RecordDetails_ModeChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewModeEventArgs) Handles RecordDetails.ModeChanging
        'Change current mode to selected one
        RecordDetails.ChangeMode(e.NewMode)
 
        'Rebind the grid
    End Sub
 
 
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
 
        DetailsView1.Visible = True
        DetailsView1.EnablePagingCallbacks = False
 
        Dim todaydate As TextBox = CType(DetailsView1.Rows(0).FindControl("TextBox1"), TextBox)
        If todaydate IsNot Nothing Then
            todaydate.Text = DateTime.Now.ToString("MM/dd/yyyy")
        End If
 
    End Sub
 
    'User has selected a single entry from the list of Requests
    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        Button1.Visible = True
        Label3.Visible = True
        
    End Sub
 
    'Refresh list of Updates after new update added
    Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs) Handles DetailsView1.ItemInserted
        GridView2.DataBind()
    End Sub
End Class

Open in new window

Record-Details.PNG
With-Update-Window.PNG
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24111666
Are you talking about DetailsView1, which is bound to ObjectDataSource4?

Aside:  Descriptive object names can be a very important, but often ignored step for self-documenting code.
0
 

Author Comment

by:SophiG
ID: 24111945
Yes, thats it.  Sorry.  I'm still working on the basics as a beginner ASP student.  Sophig
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 24112151
1) Habits should be learned early.

2) I have worked in IT for 20+ years, and there are always new things to learn, so don't be sorry.

3) I see this ObjectDataSource definition:

  <asp:ObjectDataSource ID="ObjectDataSource4" runat="server" DeleteMethod="Delete"
        InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetDataBy"
        TypeName="DataSet1TableAdapters.tblUpdatesTableAdapter" UpdateMethod="Update">
        <DeleteParameters>
            <asp:Parameter Name="Original_ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="ServiceRecordID" Type="Int32" />
            <asp:Parameter Name="U_Date" Type="DateTime" />
            <asp:Parameter Name="Updates" Type="String" />
            <asp:Parameter Name="Original_ID" Type="Int32" />
        </UpdateParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="RecordDetails" Name="ServiceRecordID" PropertyName="SelectedValue"
                Type="Int32" DefaultValue="GridView1.DataKeys[GridView1.SelectedIndex]" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="ServiceRecordID" Type="Int32" />
            <asp:Parameter Name="U_Date" Type="DateTime" />
            <asp:Parameter Name="Updates" Type="String" />
        </InsertParameters>
    </asp:ObjectDataSource>

4) This looks like you are binding a typed DataSet to a GridView through an ObjectDataSource, which doesn't make any sense to me.  The ObjectDataSource is designed to bind a list of business objects, and a typed DataSet doesn't apply).  I would use an SqlDataSource instead, which has the data stuff that you have housed in the typed DataSet.

5) You said, "The problem that I have is that the insert Comment detail view opens with all 3 fields blank".  I believe that this is happening because you are not controlling this process, but letting the controls handle this.
0
 

Author Closing Comment

by:SophiG
ID: 31567564
I'll have to take the advice of the LearnedOne and try to implement it when I have time.  Have been pulled away and not been able to prove it out at this point, but need to close the question.
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question