473,219 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,219 software developers and data experts.

Populating FormView (asp.net 2.0 using vb.net)

Hello,

I am creating a form for users to enter information about a lab and the
members of the lab. I have one form (FormView) that they use to enter
information about that lab. The keyvalue is "LabLocation_ID". With an
existing lab, they then need to add the members for that lab. So, what I am
trying to do is the following. With the FormView of the Lab open, the user
will click a button to open a FormView (InsertMode) and add a new user. My
question is, how do I copy the "LabLocation_ID" from the "Lab" FormView to
the "Member" FormView?

table structure (tblLabLocation_Member)
LabLocation_ID (varchar 200)
Member_ID (varchar 200)

--
Thanks in advance,

sck10
Dec 23 '05 #1
3 6012
Hi Sck10,

Welcome to ASPNET newsgroup.
As for the displaying master/details structure datas through the ASP.NET
2.0 databound controls, I think you can consider the following means;

use the FormView to bound to the Lab table(through a SqlDataSource), and
set the FormView's DataKeyNames to the Lab table's primary Key, and then,
declare another DataSource which select data from Member table through the
Lab_Member relation table....
we can declare a select parameter (for where clause ) in the
SqlDataSource's SelectCommand , and set the select parameter as
ControlParameter which pointed to the Lab FormView's SelectedValue
property.... After that, we can bound the second datasource to a certain
GridView or another Formview /DetailsView...... Thus, the relation
between the master/details datas is established....
Below is a sample Page which use a FormView and a GridView to display
Master/Detail data from the Northwind database's Orders and OrderDetails
tables.....

==================================
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:LocalNorthWind %>"
DeleteCommand="DELETE FROM [Orders] WHERE [OrderID] = @OrderID"
InsertCommand="INSERT INTO [Orders] ([CustomerID], [EmployeeID],
[OrderDate]) VALUES (@CustomerID, @EmployeeID, @OrderDate)"
SelectCommand="SELECT [OrderID], [CustomerID], [EmployeeID],
[OrderDate] FROM [Orders]"
UpdateCommand="UPDATE [Orders] SET [CustomerID] = @CustomerID,
[EmployeeID] = @EmployeeID, [OrderDate] = @OrderDate WHERE [OrderID] =
@OrderID">
<DeleteParameters>
<asp:Parameter Name="OrderID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="CustomerID" Type="String" />
<asp:Parameter Name="EmployeeID" Type="Int32" />
<asp:Parameter Name="OrderDate" Type="DateTime" />
<asp:Parameter Name="OrderID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="CustomerID" Type="String" />
<asp:Parameter Name="EmployeeID" Type="Int32" />
<asp:Parameter Name="OrderDate" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>

</div>
<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
DataKeyNames="OrderID"
DataSourceID="SqlDataSource1">
<EditItemTemplate>
OrderID:
<asp:Label ID="OrderIDLabel1" runat="server" Text='<%#
Eval("OrderID") %>'></asp:Label><br />
CustomerID:
<asp:TextBox ID="CustomerIDTextBox" runat="server"
Text='<%# Bind("CustomerID") %>'>
</asp:TextBox><br />
EmployeeID:
<asp:TextBox ID="EmployeeIDTextBox" runat="server"
Text='<%# Bind("EmployeeID") %>'>
</asp:TextBox><br />
OrderDate:
<asp:TextBox ID="OrderDateTextBox" runat="server" Text='<%#
Bind("OrderDate") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
CustomerID:
<asp:TextBox ID="CustomerIDTextBox" runat="server"
Text='<%# Bind("CustomerID") %>'>
</asp:TextBox><br />
EmployeeID:
<asp:TextBox ID="EmployeeIDTextBox" runat="server"
Text='<%# Bind("EmployeeID") %>'>
</asp:TextBox><br />
OrderDate:
<asp:TextBox ID="OrderDateTextBox" runat="server" Text='<%#
Bind("OrderDate") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
OrderID:
<asp:Label ID="OrderIDLabel" runat="server" Text='<%#
Eval("OrderID") %>'></asp:Label><br />
CustomerID:
<asp:Label ID="CustomerIDLabel" runat="server" Text='<%#
Bind("CustomerID") %>'>
</asp:Label><br />
EmployeeID:
<asp:Label ID="EmployeeIDLabel" runat="server" Text='<%#
Bind("EmployeeID") %>'>
</asp:Label><br />
OrderDate:
<asp:Label ID="OrderDateLabel" runat="server" Text='<%#
Bind("OrderDate") %>'></asp:Label><br />
<asp:LinkButton ID="EditButton" runat="server"
CausesValidation="False" CommandName="Edit"
Text="Edit">
</asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server"
CausesValidation="False" CommandName="Delete"
Text="Delete">
</asp:LinkButton>
<asp:LinkButton ID="NewButton" runat="server"
CausesValidation="False" CommandName="New"
Text="New">
</asp:LinkButton>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:LocalNorthWind %>"
DeleteCommand="DELETE FROM [Order Details] WHERE [OrderID] =
@OrderID AND [ProductID] = @ProductID"
InsertCommand="INSERT INTO [Order Details] ([OrderID],
[ProductID], [Discount], [Quantity], [UnitPrice]) VALUES (@OrderID,
@ProductID, @Discount, @Quantity, @UnitPrice)"
SelectCommand="SELECT [OrderID], [ProductID], [Discount],
[Quantity], [UnitPrice] FROM [Order Details] WHERE ([OrderID] = @OrderID)"
UpdateCommand="UPDATE [Order Details] SET [Discount] =
@Discount, [Quantity] = @Quantity, [UnitPrice] = @UnitPrice WHERE [OrderID]
= @OrderID AND [ProductID] = @ProductID">
<DeleteParameters>
<asp:Parameter Name="OrderID" Type="Int32" />
<asp:Parameter Name="ProductID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Discount" Type="Single" />
<asp:Parameter Name="Quantity" Type="Int16" />
<asp:Parameter Name="UnitPrice" Type="Decimal" />
<asp:Parameter Name="OrderID" Type="Int32" />
<asp:Parameter Name="ProductID" Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="FormView1" Name="OrderID"
PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="OrderID" Type="Int32" />
<asp:Parameter Name="ProductID" Type="Int32" />
<asp:Parameter Name="Discount" Type="Single" />
<asp:Parameter Name="Quantity" Type="Int16" />
<asp:Parameter Name="UnitPrice" Type="Decimal" />
</InsertParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="OrderID,ProductID"
DataSourceID="SqlDataSource2">
<Columns>
<asp:CommandField ShowEditButton="True"
ShowSelectButton="True" />
<asp:BoundField DataField="OrderID" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" />
<asp:BoundField DataField="ProductID"
HeaderText="ProductID" ReadOnly="True" SortExpression="ProductID" />
<asp:BoundField DataField="Discount" HeaderText="Discount"
SortExpression="Discount" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity"
SortExpression="Quantity" />
<asp:BoundField DataField="UnitPrice"
HeaderText="UnitPrice" SortExpression="UnitPrice" />
</Columns>
</asp:GridView>
</form>
========================

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "sck10" <sc***@online.nospam>
| Subject: Populating FormView (asp.net 2.0 using vb.net)
| Date: Thu, 22 Dec 2005 17:57:59 -0600
| Lines: 21
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
| Message-ID: <eS**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 189.202.185.135.in-addr.arpa 135.185.202.189
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:366683
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hello,
|
| I am creating a form for users to enter information about a lab and the
| members of the lab. I have one form (FormView) that they use to enter
| information about that lab. The keyvalue is "LabLocation_ID". With an
| existing lab, they then need to add the members for that lab. So, what I
am
| trying to do is the following. With the FormView of the Lab open, the
user
| will click a button to open a FormView (InsertMode) and add a new user.
My
| question is, how do I copy the "LabLocation_ID" from the "Lab" FormView to
| the "Member" FormView?
|
| table structure (tblLabLocation_Member)
| LabLocation_ID (varchar 200)
| Member_ID (varchar 200)
|
| --
| Thanks in advance,
|
| sck10
|
|
|

Dec 23 '05 #2
Hi Steven,

I'd like to do something like this, but my problem is the fact that I have a
list of the members and have to add some of them to a new lab. I've done
something similar in vs 2003 with the strongly typed Dataset. This solution
helps me to save all changes only after final submit. Is there a better way
to do so in vs 2005.

Thanks,

Vlad Sadilov

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:QZ**************@TK2MSFTNGXA02.phx.gbl...
Hi Sck10,

Welcome to ASPNET newsgroup.
As for the displaying master/details structure datas through the ASP.NET
2.0 databound controls, I think you can consider the following means;

use the FormView to bound to the Lab table(through a SqlDataSource), and
set the FormView's DataKeyNames to the Lab table's primary Key, and
then,
declare another DataSource which select data from Member table through the
Lab_Member relation table....
we can declare a select parameter (for where clause ) in the
SqlDataSource's SelectCommand , and set the select parameter as
ControlParameter which pointed to the Lab FormView's SelectedValue
property.... After that, we can bound the second datasource to a certain
GridView or another Formview /DetailsView...... Thus, the relation
between the master/details datas is established....
Below is a sample Page which use a FormView and a GridView to display
Master/Detail data from the Northwind database's Orders and OrderDetails
tables.....

==================================
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:LocalNorthWind %>"
DeleteCommand="DELETE FROM [Orders] WHERE [OrderID] = @OrderID"
InsertCommand="INSERT INTO [Orders] ([CustomerID], [EmployeeID],
[OrderDate]) VALUES (@CustomerID, @EmployeeID, @OrderDate)"
SelectCommand="SELECT [OrderID], [CustomerID], [EmployeeID],
[OrderDate] FROM [Orders]"
UpdateCommand="UPDATE [Orders] SET [CustomerID] = @CustomerID,
[EmployeeID] = @EmployeeID, [OrderDate] = @OrderDate WHERE [OrderID] =
@OrderID">
<DeleteParameters>
<asp:Parameter Name="OrderID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="CustomerID" Type="String" />
<asp:Parameter Name="EmployeeID" Type="Int32" />
<asp:Parameter Name="OrderDate" Type="DateTime" />
<asp:Parameter Name="OrderID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="CustomerID" Type="String" />
<asp:Parameter Name="EmployeeID" Type="Int32" />
<asp:Parameter Name="OrderDate" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>

</div>
<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
DataKeyNames="OrderID"
DataSourceID="SqlDataSource1">
<EditItemTemplate>
OrderID:
<asp:Label ID="OrderIDLabel1" runat="server" Text='<%#
Eval("OrderID") %>'></asp:Label><br />
CustomerID:
<asp:TextBox ID="CustomerIDTextBox" runat="server"
Text='<%# Bind("CustomerID") %>'>
</asp:TextBox><br />
EmployeeID:
<asp:TextBox ID="EmployeeIDTextBox" runat="server"
Text='<%# Bind("EmployeeID") %>'>
</asp:TextBox><br />
OrderDate:
<asp:TextBox ID="OrderDateTextBox" runat="server" Text='<%#
Bind("OrderDate") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
CustomerID:
<asp:TextBox ID="CustomerIDTextBox" runat="server"
Text='<%# Bind("CustomerID") %>'>
</asp:TextBox><br />
EmployeeID:
<asp:TextBox ID="EmployeeIDTextBox" runat="server"
Text='<%# Bind("EmployeeID") %>'>
</asp:TextBox><br />
OrderDate:
<asp:TextBox ID="OrderDateTextBox" runat="server" Text='<%#
Bind("OrderDate") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
OrderID:
<asp:Label ID="OrderIDLabel" runat="server" Text='<%#
Eval("OrderID") %>'></asp:Label><br />
CustomerID:
<asp:Label ID="CustomerIDLabel" runat="server" Text='<%#
Bind("CustomerID") %>'>
</asp:Label><br />
EmployeeID:
<asp:Label ID="EmployeeIDLabel" runat="server" Text='<%#
Bind("EmployeeID") %>'>
</asp:Label><br />
OrderDate:
<asp:Label ID="OrderDateLabel" runat="server" Text='<%#
Bind("OrderDate") %>'></asp:Label><br />
<asp:LinkButton ID="EditButton" runat="server"
CausesValidation="False" CommandName="Edit"
Text="Edit">
</asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server"
CausesValidation="False" CommandName="Delete"
Text="Delete">
</asp:LinkButton>
<asp:LinkButton ID="NewButton" runat="server"
CausesValidation="False" CommandName="New"
Text="New">
</asp:LinkButton>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:LocalNorthWind %>"
DeleteCommand="DELETE FROM [Order Details] WHERE [OrderID] =
@OrderID AND [ProductID] = @ProductID"
InsertCommand="INSERT INTO [Order Details] ([OrderID],
[ProductID], [Discount], [Quantity], [UnitPrice]) VALUES (@OrderID,
@ProductID, @Discount, @Quantity, @UnitPrice)"
SelectCommand="SELECT [OrderID], [ProductID], [Discount],
[Quantity], [UnitPrice] FROM [Order Details] WHERE ([OrderID] = @OrderID)"
UpdateCommand="UPDATE [Order Details] SET [Discount] =
@Discount, [Quantity] = @Quantity, [UnitPrice] = @UnitPrice WHERE
[OrderID]
= @OrderID AND [ProductID] = @ProductID">
<DeleteParameters>
<asp:Parameter Name="OrderID" Type="Int32" />
<asp:Parameter Name="ProductID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Discount" Type="Single" />
<asp:Parameter Name="Quantity" Type="Int16" />
<asp:Parameter Name="UnitPrice" Type="Decimal" />
<asp:Parameter Name="OrderID" Type="Int32" />
<asp:Parameter Name="ProductID" Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="FormView1" Name="OrderID"
PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="OrderID" Type="Int32" />
<asp:Parameter Name="ProductID" Type="Int32" />
<asp:Parameter Name="Discount" Type="Single" />
<asp:Parameter Name="Quantity" Type="Int16" />
<asp:Parameter Name="UnitPrice" Type="Decimal" />
</InsertParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="OrderID,ProductID"
DataSourceID="SqlDataSource2">
<Columns>
<asp:CommandField ShowEditButton="True"
ShowSelectButton="True" />
<asp:BoundField DataField="OrderID" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" />
<asp:BoundField DataField="ProductID"
HeaderText="ProductID" ReadOnly="True" SortExpression="ProductID" />
<asp:BoundField DataField="Discount" HeaderText="Discount"
SortExpression="Discount" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity"
SortExpression="Quantity" />
<asp:BoundField DataField="UnitPrice"
HeaderText="UnitPrice" SortExpression="UnitPrice" />
</Columns>
</asp:GridView>
</form>
========================

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "sck10" <sc***@online.nospam>
| Subject: Populating FormView (asp.net 2.0 using vb.net)
| Date: Thu, 22 Dec 2005 17:57:59 -0600
| Lines: 21
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
| Message-ID: <eS**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 189.202.185.135.in-addr.arpa 135.185.202.189
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:366683
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hello,
|
| I am creating a form for users to enter information about a lab and the
| members of the lab. I have one form (FormView) that they use to enter
| information about that lab. The keyvalue is "LabLocation_ID". With an
| existing lab, they then need to add the members for that lab. So, what
I
am
| trying to do is the following. With the FormView of the Lab open, the
user
| will click a button to open a FormView (InsertMode) and add a new user.
My
| question is, how do I copy the "LabLocation_ID" from the "Lab" FormView
to
| the "Member" FormView?
|
| table structure (tblLabLocation_Member)
| LabLocation_ID (varchar 200)
| Member_ID (varchar 200)
|
| --
| Thanks in advance,
|
| sck10
|
|
|

Dec 25 '05 #3
Hi Vlad,

If you want complex customization, the typed DataSet components are still
available in asp.net/ado.net 2.0 and they're even enhanced by the new
DataSet/TableAdapter components:

#TableAdapter Overview
http://msdn2.microsoft.com/en-us/library/bz9tthwx.aspx

#How to: Directly Access the Database with a TableAdapter
http://msdn2.microsoft.com/en-us/library/ms171935.aspx

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "Vlad Sadilov" <v_*******@hotmail.com>
| References: <eS**************@TK2MSFTNGP12.phx.gbl>
<QZ**************@TK2MSFTNGXA02.phx.gbl>
| Subject: Re: Populating FormView (asp.net 2.0 using vb.net)
| Date: Sun, 25 Dec 2005 01:37:41 +0100
| Lines: 258
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| X-RFC2646: Format=Flowed; Original
| Message-ID: <#k**************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: host107-73.pool80104.interbusiness.it 80.104.73.107
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:366962
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi Steven,
|
| I'd like to do something like this, but my problem is the fact that I
have a
| list of the members and have to add some of them to a new lab. I've done
| something similar in vs 2003 with the strongly typed Dataset. This
solution
| helps me to save all changes only after final submit. Is there a better
way
| to do so in vs 2005.
|
| Thanks,
|
| Vlad Sadilov
|
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:QZ**************@TK2MSFTNGXA02.phx.gbl...
| > Hi Sck10,
| >
| > Welcome to ASPNET newsgroup.
| > As for the displaying master/details structure datas through the ASP.NET
| > 2.0 databound controls, I think you can consider the following means;
| >
| > use the FormView to bound to the Lab table(through a SqlDataSource), and
| > set the FormView's DataKeyNames to the Lab table's primary Key, and
| > then,
| > declare another DataSource which select data from Member table through
the
| > Lab_Member relation table....
| > we can declare a select parameter (for where clause ) in the
| > SqlDataSource's SelectCommand , and set the select parameter as
| > ControlParameter which pointed to the Lab FormView's SelectedValue
| > property.... After that, we can bound the second datasource to a
certain
| > GridView or another Formview /DetailsView...... Thus, the relation
| > between the master/details datas is established....
| > Below is a sample Page which use a FormView and a GridView to display
| > Master/Detail data from the Northwind database's Orders and
OrderDetails
| > tables.....
| >
| > ==================================
| > <form id="form1" runat="server">
| > <div>
| > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
| > ConnectionString="<%$ ConnectionStrings:LocalNorthWind %>"
| > DeleteCommand="DELETE FROM [Orders] WHERE [OrderID] =
@OrderID"
| > InsertCommand="INSERT INTO [Orders] ([CustomerID], [EmployeeID],
| > [OrderDate]) VALUES (@CustomerID, @EmployeeID, @OrderDate)"
| > SelectCommand="SELECT [OrderID], [CustomerID], [EmployeeID],
| > [OrderDate] FROM [Orders]"
| > UpdateCommand="UPDATE [Orders] SET [CustomerID] =
@CustomerID,
| > [EmployeeID] = @EmployeeID, [OrderDate] = @OrderDate WHERE [OrderID] =
| > @OrderID">
| > <DeleteParameters>
| > <asp:Parameter Name="OrderID" Type="Int32" />
| > </DeleteParameters>
| > <UpdateParameters>
| > <asp:Parameter Name="CustomerID" Type="String" />
| > <asp:Parameter Name="EmployeeID" Type="Int32" />
| > <asp:Parameter Name="OrderDate" Type="DateTime" />
| > <asp:Parameter Name="OrderID" Type="Int32" />
| > </UpdateParameters>
| > <InsertParameters>
| > <asp:Parameter Name="CustomerID" Type="String" />
| > <asp:Parameter Name="EmployeeID" Type="Int32" />
| > <asp:Parameter Name="OrderDate" Type="DateTime" />
| > </InsertParameters>
| > </asp:SqlDataSource>
| >
| > </div>
| > <asp:FormView ID="FormView1" runat="server" AllowPaging="True"
| > DataKeyNames="OrderID"
| > DataSourceID="SqlDataSource1">
| > <EditItemTemplate>
| > OrderID:
| > <asp:Label ID="OrderIDLabel1" runat="server" Text='<%#
| > Eval("OrderID") %>'></asp:Label><br />
| > CustomerID:
| > <asp:TextBox ID="CustomerIDTextBox" runat="server"
| > Text='<%# Bind("CustomerID") %>'>
| > </asp:TextBox><br />
| > EmployeeID:
| > <asp:TextBox ID="EmployeeIDTextBox" runat="server"
| > Text='<%# Bind("EmployeeID") %>'>
| > </asp:TextBox><br />
| > OrderDate:
| > <asp:TextBox ID="OrderDateTextBox" runat="server"
Text='<%#
| > Bind("OrderDate") %>'>
| > </asp:TextBox><br />
| > <asp:LinkButton ID="UpdateButton" runat="server"
| > CausesValidation="True" CommandName="Update"
| > Text="Update">
| > </asp:LinkButton>
| > <asp:LinkButton ID="UpdateCancelButton" runat="server"
| > CausesValidation="False" CommandName="Cancel"
| > Text="Cancel">
| > </asp:LinkButton>
| > </EditItemTemplate>
| > <InsertItemTemplate>
| > CustomerID:
| > <asp:TextBox ID="CustomerIDTextBox" runat="server"
| > Text='<%# Bind("CustomerID") %>'>
| > </asp:TextBox><br />
| > EmployeeID:
| > <asp:TextBox ID="EmployeeIDTextBox" runat="server"
| > Text='<%# Bind("EmployeeID") %>'>
| > </asp:TextBox><br />
| > OrderDate:
| > <asp:TextBox ID="OrderDateTextBox" runat="server"
Text='<%#
| > Bind("OrderDate") %>'>
| > </asp:TextBox><br />
| > <asp:LinkButton ID="InsertButton" runat="server"
| > CausesValidation="True" CommandName="Insert"
| > Text="Insert">
| > </asp:LinkButton>
| > <asp:LinkButton ID="InsertCancelButton" runat="server"
| > CausesValidation="False" CommandName="Cancel"
| > Text="Cancel">
| > </asp:LinkButton>
| > </InsertItemTemplate>
| > <ItemTemplate>
| > OrderID:
| > <asp:Label ID="OrderIDLabel" runat="server" Text='<%#
| > Eval("OrderID") %>'></asp:Label><br />
| > CustomerID:
| > <asp:Label ID="CustomerIDLabel" runat="server" Text='<%#
| > Bind("CustomerID") %>'>
| > </asp:Label><br />
| > EmployeeID:
| > <asp:Label ID="EmployeeIDLabel" runat="server" Text='<%#
| > Bind("EmployeeID") %>'>
| > </asp:Label><br />
| > OrderDate:
| > <asp:Label ID="OrderDateLabel" runat="server" Text='<%#
| > Bind("OrderDate") %>'></asp:Label><br />
| > <asp:LinkButton ID="EditButton" runat="server"
| > CausesValidation="False" CommandName="Edit"
| > Text="Edit">
| > </asp:LinkButton>
| > <asp:LinkButton ID="DeleteButton" runat="server"
| > CausesValidation="False" CommandName="Delete"
| > Text="Delete">
| > </asp:LinkButton>
| > <asp:LinkButton ID="NewButton" runat="server"
| > CausesValidation="False" CommandName="New"
| > Text="New">
| > </asp:LinkButton>
| > </ItemTemplate>
| > </asp:FormView>
| > <asp:SqlDataSource ID="SqlDataSource2" runat="server"
| > ConnectionString="<%$ ConnectionStrings:LocalNorthWind %>"
| > DeleteCommand="DELETE FROM [Order Details] WHERE [OrderID] =
| > @OrderID AND [ProductID] = @ProductID"
| > InsertCommand="INSERT INTO [Order Details] ([OrderID],
| > [ProductID], [Discount], [Quantity], [UnitPrice]) VALUES (@OrderID,
| > @ProductID, @Discount, @Quantity, @UnitPrice)"
| > SelectCommand="SELECT [OrderID], [ProductID], [Discount],
| > [Quantity], [UnitPrice] FROM [Order Details] WHERE ([OrderID] =
@OrderID)"
| > UpdateCommand="UPDATE [Order Details] SET [Discount] =
| > @Discount, [Quantity] = @Quantity, [UnitPrice] = @UnitPrice WHERE
| > [OrderID]
| > = @OrderID AND [ProductID] = @ProductID">
| > <DeleteParameters>
| > <asp:Parameter Name="OrderID" Type="Int32" />
| > <asp:Parameter Name="ProductID" Type="Int32" />
| > </DeleteParameters>
| > <UpdateParameters>
| > <asp:Parameter Name="Discount" Type="Single" />
| > <asp:Parameter Name="Quantity" Type="Int16" />
| > <asp:Parameter Name="UnitPrice" Type="Decimal" />
| > <asp:Parameter Name="OrderID" Type="Int32" />
| > <asp:Parameter Name="ProductID" Type="Int32" />
| > </UpdateParameters>
| > <SelectParameters>
| > <asp:ControlParameter ControlID="FormView1"
Name="OrderID"
| > PropertyName="SelectedValue"
| > Type="Int32" />
| > </SelectParameters>
| > <InsertParameters>
| > <asp:Parameter Name="OrderID" Type="Int32" />
| > <asp:Parameter Name="ProductID" Type="Int32" />
| > <asp:Parameter Name="Discount" Type="Single" />
| > <asp:Parameter Name="Quantity" Type="Int16" />
| > <asp:Parameter Name="UnitPrice" Type="Decimal" />
| > </InsertParameters>
| > </asp:SqlDataSource>
| > <asp:GridView ID="GridView1" runat="server"
| > AutoGenerateColumns="False" DataKeyNames="OrderID,ProductID"
| > DataSourceID="SqlDataSource2">
| > <Columns>
| > <asp:CommandField ShowEditButton="True"
| > ShowSelectButton="True" />
| > <asp:BoundField DataField="OrderID" HeaderText="OrderID"
| > ReadOnly="True" SortExpression="OrderID" />
| > <asp:BoundField DataField="ProductID"
| > HeaderText="ProductID" ReadOnly="True" SortExpression="ProductID" />
| > <asp:BoundField DataField="Discount"
HeaderText="Discount"
| > SortExpression="Discount" />
| > <asp:BoundField DataField="Quantity"
HeaderText="Quantity"
| > SortExpression="Quantity" />
| > <asp:BoundField DataField="UnitPrice"
| > HeaderText="UnitPrice" SortExpression="UnitPrice" />
| > </Columns>
| > </asp:GridView>
| > </form>
| > ========================
| >
| > Hope helps. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| > --------------------
| > | From: "sck10" <sc***@online.nospam>
| > | Subject: Populating FormView (asp.net 2.0 using vb.net)
| > | Date: Thu, 22 Dec 2005 17:57:59 -0600
| > | Lines: 21
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
| > | Message-ID: <eS**************@TK2MSFTNGP12.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: 189.202.185.135.in-addr.arpa 135.185.202.189
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:366683
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | Hello,
| > |
| > | I am creating a form for users to enter information about a lab and
the
| > | members of the lab. I have one form (FormView) that they use to enter
| > | information about that lab. The keyvalue is "LabLocation_ID". With
an
| > | existing lab, they then need to add the members for that lab. So,
what
| > I
| > am
| > | trying to do is the following. With the FormView of the Lab open, the
| > user
| > | will click a button to open a FormView (InsertMode) and add a new
user.
| > My
| > | question is, how do I copy the "LabLocation_ID" from the "Lab"
FormView
| > to
| > | the "Member" FormView?
| > |
| > | table structure (tblLabLocation_Member)
| > | LabLocation_ID (varchar 200)
| > | Member_ID (varchar 200)
| > |
| > | --
| > | Thanks in advance,
| > |
| > | sck10
| > |
| > |
| > |
| >
|
|
|

Dec 26 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: TdarTdar | last post by:
I wanted to add three columns up on the form and run some logic to fill in the third but not sure how to call the field names in the formview control. Dim Girth As Integer Elenght =...
1
by: sck10 | last post by:
Hello, I am pulling data from a SQL Server table. One field that is (varchar 4000) is used to show notes. I am using a FormView for showing and editing the data. When the form is in Item...
0
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase...
1
by: Andre | last post by:
Hi, I try to change some value in the databind of my formview, but can't find a way to dot it. In Asp.net 1.1 i was using someting like this : Public Sub item_bound(ByVal sender As...
7
by: Lorenzino | last post by:
Hi, I have a problem with bindings in a formview. I have a formview; in the insert template i've created a wizard control and inside it i have an HTML table with some textboxes bound to the...
2
by: Kelly | last post by:
I'm fairly new to ASP.NET2, but I have an ASP 3.0 background, and I've been experimenting with the DataSource and FormView widgets. I wound up having some questions along the way which I hope you...
1
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
3
by: YMPN | last post by:
Hi Everyone, I'm deen from Riyadh. Please do help me with some problem i have. I have this formview control setup to recieved inputs from user (textbox, dropdownlist, others). After...
1
by: Trev | last post by:
Hi, I'm hoping that someone in this group can shed some light on an issue I'm having with a Formview. I have a Web User Control (.ascx) with a Formview. The Formview contains 2 Multiviews,...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.