Home All Groups Group Topic Archive Search About

Itemtemplace and many to one dropdown example wanted

Author
21 Jan 2006 1:37 AM
TdarTdar
Where can i find an expample of a item template that does the following

example of detailsview


name:  Jack
City:   2342
State:  1


I want to change the city field I assume using Itemtemplate, and have
it link to a city table(another table) as a dropdown to display the city
name.

Author
23 Jan 2006 7:48 AM
Steven Cheng[MSFT]
Hi Tdar,

Welcome.
Regarding on the question you mentioned, do you mean that you want to
display one of the column in DetailsView as a DropDownList and the
dropdownlist's items will be filled by data retrieved from another database
table?

If so, a simple means is add an another DataSource control which connect to
the data table that contains the DropDownList's items data....  Then, in
our main DataBound  control(DetailsView?), we add a dropdownlist and set
its datasourceID to the new datasource control and bind its selectedValue
to the original databound value ......

To make it clear, here is a simple example which display the Product
table's data in a DetailsView control, and it contains one column which
display the Category through a DropDownList....

==========aspx=============
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
               <asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            SelectCommand="SELECT [ProductID], [ProductName], [CategoryID]
FROM [Products]" DeleteCommand="DELETE FROM [Products] WHERE [ProductID] =
@ProductID" InsertCommand="INSERT INTO [Products] ([ProductName],
[CategoryID]) VALUES (@ProductName, @CategoryID)" UpdateCommand="UPDATE
[Products] SET [ProductName] = @ProductName, [CategoryID] = @CategoryID
WHERE [ProductID] = @ProductID">
            <DeleteParameters>
                <asp:Parameter Name="ProductID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="ProductName" Type="String" />
                <asp:Parameter Name="CategoryID" Type="Int32" />
                <asp:Parameter Name="ProductID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="ProductName" Type="String" />
                <asp:Parameter Name="CategoryID" Type="Int32" />
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            SelectCommand="SELECT [CategoryID], [CategoryName] FROM
[Categories]"></asp:SqlDataSource>
        <asp:DetailsView ID="DetailsView1" runat="server"
AutoGenerateRows="False" DataKeyNames="ProductID"
            DataSourceID="SqlDataSource1" Height="50px" Width="125px"
AllowPaging="True">
            <Fields>
                <asp:BoundField DataField="ProductID"
HeaderText="ProductID" InsertVisible="False"
                    ReadOnly="True" SortExpression="ProductID" />
                <asp:BoundField DataField="ProductName"
HeaderText="ProductName" SortExpression="ProductName" />
                <asp:TemplateField HeaderText="CategoryID"
SortExpression="CategoryID">
                    <EditItemTemplate>
                        &nbsp;<asp:DropDownList ID="DropDownList1"
runat="server" DataSourceID="SqlDataSource2"
                            DataTextField="CategoryName"
DataValueField="CategoryID" SelectedValue='<%# Bind("CategoryID") %>'>
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("CategoryID") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        &nbsp;<asp:DropDownList ID="DropDownList2"
runat="server" DataSourceID="SqlDataSource2"
                            DataTextField="CategoryName"
DataValueField="CategoryID" Enabled="False" SelectedValue='<%#
Bind("CategoryID") %>'>
                        </asp:DropDownList>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowEditButton="True" />
            </Fields>
        </asp:DetailsView>
    </div>
    </form>
</body>
</html>
=======================

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.)







--------------------
Show quoteHide quote
| Thread-Topic: Itemtemplace and many to one dropdown example wanted
| thread-index: AcYeKy7odVEPNOMCTeO27jfTJ/6shA==
| X-WBNR-Posting-Host: 65.35.95.187
| From: "=?Utf-8?B?VGRhclRkYXI=?=" <Tdar@noemail.nospam>
| Subject: Itemtemplace and many to one dropdown example wanted
| Date: Fri, 20 Jan 2006 17:37:04 -0800
| Lines: 14
| Message-ID: <DB561767-E612-4C0E-A000-91321BDF2***@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
|     charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:32702
Show quoteHide quote
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Where can i find an expample of a item template that does the following
|
| example of detailsview
|
|
| name:  Jack
| City:   2342
| State:  1
|
|
| I want to change the city field I assume using Itemtemplate, and have
| it link to a city table(another table) as a dropdown to display the city
| name. 
|
|
Author
23 Jan 2006 5:51 PM
TdarTdar
Hi,
Thanks that helped, but how to a change one dropdown contents based on
anothers current selection.

as in selected state is "FL"

so the cities dropdown in edit mode should only show "Citys" in "FL"

I tried this but get an error:
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$
ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
        SelectCommand="SELECT [StateKey], [StateName], [StateCode] FROM
[State] where StateKey = <%# Bind("StateKey") %> Order by
[StateName]"></asp:SqlDataSource>

I guess the bind statement is not valid at that time of form loading.

Tdar



Show quoteHide quote
"Steven Cheng[MSFT]" wrote:

> Hi Tdar,
>
> Welcome.
> Regarding on the question you mentioned, do you mean that you want to
> display one of the column in DetailsView as a DropDownList and the
> dropdownlist's items will be filled by data retrieved from another database
> table?
>
> If so, a simple means is add an another DataSource control which connect to
> the data table that contains the DropDownList's items data....  Then, in
> our main DataBound  control(DetailsView?), we add a dropdownlist and set
> its datasourceID to the new datasource control and bind its selectedValue
> to the original databound value ......
>
> To make it clear, here is a simple example which display the Product
> table's data in a DetailsView control, and it contains one column which
> display the Category through a DropDownList....
>
> ==========aspx=============
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
>     <title>Untitled Page</title>
> </head>
> <body>
>     <form id="form1" runat="server">
>     <div>
>                <asp:SqlDataSource ID="SqlDataSource1" runat="server"
> ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
>             SelectCommand="SELECT [ProductID], [ProductName], [CategoryID]
> FROM [Products]" DeleteCommand="DELETE FROM [Products] WHERE [ProductID] =
> @ProductID" InsertCommand="INSERT INTO [Products] ([ProductName],
> [CategoryID]) VALUES (@ProductName, @CategoryID)" UpdateCommand="UPDATE
> [Products] SET [ProductName] = @ProductName, [CategoryID] = @CategoryID
> WHERE [ProductID] = @ProductID">
>             <DeleteParameters>
>                 <asp:Parameter Name="ProductID" Type="Int32" />
>             </DeleteParameters>
>             <UpdateParameters>
>                 <asp:Parameter Name="ProductName" Type="String" />
>                 <asp:Parameter Name="CategoryID" Type="Int32" />
>                 <asp:Parameter Name="ProductID" Type="Int32" />
>             </UpdateParameters>
>             <InsertParameters>
>                 <asp:Parameter Name="ProductName" Type="String" />
>                 <asp:Parameter Name="CategoryID" Type="Int32" />
>             </InsertParameters>
>         </asp:SqlDataSource>
>         <asp:SqlDataSource ID="SqlDataSource2" runat="server"
> ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
>             SelectCommand="SELECT [CategoryID], [CategoryName] FROM
> [Categories]"></asp:SqlDataSource>
>         <asp:DetailsView ID="DetailsView1" runat="server"
> AutoGenerateRows="False" DataKeyNames="ProductID"
>             DataSourceID="SqlDataSource1" Height="50px" Width="125px"
> AllowPaging="True">
>             <Fields>
>                 <asp:BoundField DataField="ProductID"
> HeaderText="ProductID" InsertVisible="False"
>                     ReadOnly="True" SortExpression="ProductID" />
>                 <asp:BoundField DataField="ProductName"
> HeaderText="ProductName" SortExpression="ProductName" />
>                 <asp:TemplateField HeaderText="CategoryID"
> SortExpression="CategoryID">
>                     <EditItemTemplate>
>                          <asp:DropDownList ID="DropDownList1"
> runat="server" DataSourceID="SqlDataSource2"
>                             DataTextField="CategoryName"
> DataValueField="CategoryID" SelectedValue='<%# Bind("CategoryID") %>'>
>                         </asp:DropDownList>
>                     </EditItemTemplate>
>                     <InsertItemTemplate>
>                         <asp:TextBox ID="TextBox1" runat="server" Text='<%#
> Bind("CategoryID") %>'></asp:TextBox>
>                     </InsertItemTemplate>
>                     <ItemTemplate>
>                          <asp:DropDownList ID="DropDownList2"
> runat="server" DataSourceID="SqlDataSource2"
>                             DataTextField="CategoryName"
> DataValueField="CategoryID" Enabled="False" SelectedValue='<%#
> Bind("CategoryID") %>'>
>                         </asp:DropDownList>
>                     </ItemTemplate>
>                 </asp:TemplateField>
>                 <asp:CommandField ShowEditButton="True" />
>             </Fields>
>         </asp:DetailsView>
>     </div>
>     </form>
> </body>
> </html>
> =======================
>
> 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.)
>
>
>
>
>
>
>
> --------------------
> | Thread-Topic: Itemtemplace and many to one dropdown example wanted
> | thread-index: AcYeKy7odVEPNOMCTeO27jfTJ/6shA==
> | X-WBNR-Posting-Host: 65.35.95.187
> | From: "=?Utf-8?B?VGRhclRkYXI=?=" <Tdar@noemail.nospam>
> | Subject: Itemtemplace and many to one dropdown example wanted
> | Date: Fri, 20 Jan 2006 17:37:04 -0800
> | Lines: 14
> | Message-ID: <DB561767-E612-4C0E-A000-91321BDF2***@microsoft.com>
> | MIME-Version: 1.0
> | Content-Type: text/plain;
> |     charset="Utf-8"
> | Content-Transfer-Encoding: 7bit
> | X-Newsreader: Microsoft CDO for Windows 2000
> | Content-Class: urn:content-classes:message
> | Importance: normal
> | Priority: normal
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
> | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
> | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
> | Xref: TK2MSFTNGXA02.phx.gbl
> microsoft.public.dotnet.framework.aspnet.webcontrols:32702
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
> |
> | Where can i find an expample of a item template that does the following
> |
> | example of detailsview
> |
> |
> | name:  Jack
> | City:   2342
> | State:  1
> |
> |
> | I want to change the city field I assume using Itemtemplate, and have
> | it link to a city table(another table) as a dropdown to display the city
> | name. 
> |
> |
>
>
Author
24 Jan 2006 7:33 AM
Steven Cheng[MSFT]
Thanks for your response Tdar,

So your actual scenario is a bit more complex than I've expected.  As you
mentioned:

====================
but how to a change one dropdown contents based on anothers current
selection.
=======================

do you mean that there is another dropdownlist control(state info) which is
used as filter of the City dropdownlist? If so, I think how to bind the
dropdownlists depend on their relationship in the control collection. Are
they put in the same parent control (a certain column in
GridView/DetailsView or ....)? 

Please feel free to let me know if there's anything I misunderstood.

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.)

--------------------
| Thread-Topic: Itemtemplace and many to one dropdown example wanted
| thread-index: AcYgRZOzuS1EF2bwSpGIUCSqYZPYaQ==
| X-WBNR-Posting-Host: 24.73.223.27
| From: "=?Utf-8?B?VGRhclRkYXI=?=" <Tdar@noemail.nospam>
| References:  <DB561767-E612-4C0E-A000-91321BDF2***@microsoft.com>
<d0xSqF$HGHA.3***@TK2MSFTNGXA02.phx.gbl>
Show quoteHide quote
| Subject: RE: Itemtemplace and many to one dropdown example wanted
| Date: Mon, 23 Jan 2006 09:51:02 -0800
| Lines: 172
| Message-ID: <77EA8A99-ADF2-41D9-BEC3-75547BDB0***@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
|     charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:32750
Show quoteHide quote
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Hi,
|  Thanks that helped, but how to a change one dropdown contents based on
| anothers current selection.
|
| as in selected state is "FL"
|
| so the cities dropdown in edit mode should only show "Citys" in "FL"
|
| I tried this but get an error:
| <asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$
| ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
|         SelectCommand="SELECT [StateKey], [StateName], [StateCode] FROM
| [State] where StateKey = <%# Bind("StateKey") %> Order by
| [StateName]"></asp:SqlDataSource>
|
| I guess the bind statement is not valid at that time of form loading.
|
| Tdar
|
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi Tdar,
| >
| > Welcome.
| > Regarding on the question you mentioned, do you mean that you want to
| > display one of the column in DetailsView as a DropDownList and the
| > dropdownlist's items will be filled by data retrieved from another
database
| > table?
| >
| > If so, a simple means is add an another DataSource control which
connect to
| > the data table that contains the DropDownList's items data....  Then,
in
| > our main DataBound  control(DetailsView?), we add a dropdownlist and
set
| > its datasourceID to the new datasource control and bind its
selectedValue
| > to the original databound value ......
| >
| > To make it clear, here is a simple example which display the Product
| > table's data in a DetailsView control, and it contains one column which
| > display the Category through a DropDownList....
| >
| > ==========aspx=============
| > <html xmlns="http://www.w3.org/1999/xhtml" >
| > <head runat="server">
| >     <title>Untitled Page</title>
| > </head>
| > <body>
| >     <form id="form1" runat="server">
| >     <div>
| >                <asp:SqlDataSource ID="SqlDataSource1" runat="server"
| > ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
| >             SelectCommand="SELECT [ProductID], [ProductName],
[CategoryID]
| > FROM [Products]" DeleteCommand="DELETE FROM [Products] WHERE
[ProductID] =
| > @ProductID" InsertCommand="INSERT INTO [Products] ([ProductName],
| > [CategoryID]) VALUES (@ProductName, @CategoryID)" UpdateCommand="UPDATE
| > [Products] SET [ProductName] = @ProductName, [CategoryID] = @CategoryID
| > WHERE [ProductID] = @ProductID">
| >             <DeleteParameters>
| >                 <asp:Parameter Name="ProductID" Type="Int32" />
| >             </DeleteParameters>
| >             <UpdateParameters>
| >                 <asp:Parameter Name="ProductName" Type="String" />
| >                 <asp:Parameter Name="CategoryID" Type="Int32" />
| >                 <asp:Parameter Name="ProductID" Type="Int32" />
| >             </UpdateParameters>
| >             <InsertParameters>
| >                 <asp:Parameter Name="ProductName" Type="String" />
| >                 <asp:Parameter Name="CategoryID" Type="Int32" />
| >             </InsertParameters>
| >         </asp:SqlDataSource>
| >         <asp:SqlDataSource ID="SqlDataSource2" runat="server"
| > ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
| >             SelectCommand="SELECT [CategoryID], [CategoryName] FROM
| > [Categories]"></asp:SqlDataSource>
| >         <asp:DetailsView ID="DetailsView1" runat="server"
| > AutoGenerateRows="False" DataKeyNames="ProductID"
| >             DataSourceID="SqlDataSource1" Height="50px" Width="125px"
| > AllowPaging="True">
| >             <Fields>
| >                 <asp:BoundField DataField="ProductID"
| > HeaderText="ProductID" InsertVisible="False"
| >                     ReadOnly="True" SortExpression="ProductID" />
| >                 <asp:BoundField DataField="ProductName"
| > HeaderText="ProductName" SortExpression="ProductName" />
| >                 <asp:TemplateField HeaderText="CategoryID"
| > SortExpression="CategoryID">
| >                     <EditItemTemplate>
| >                          <asp:DropDownList ID="DropDownList1"
| > runat="server" DataSourceID="SqlDataSource2"
| >                             DataTextField="CategoryName"
| > DataValueField="CategoryID" SelectedValue='<%# Bind("CategoryID") %>'>
| >                         </asp:DropDownList>
| >                     </EditItemTemplate>
| >                     <InsertItemTemplate>
| >                         <asp:TextBox ID="TextBox1" runat="server"
Text='<%#
| > Bind("CategoryID") %>'></asp:TextBox>
| >                     </InsertItemTemplate>
| >                     <ItemTemplate>
| >                          <asp:DropDownList ID="DropDownList2"
| > runat="server" DataSourceID="SqlDataSource2"
| >                             DataTextField="CategoryName"
| > DataValueField="CategoryID" Enabled="False" SelectedValue='<%#
| > Bind("CategoryID") %>'>
| >                         </asp:DropDownList>
| >                     </ItemTemplate>
| >                 </asp:TemplateField>
| >                 <asp:CommandField ShowEditButton="True" />
| >             </Fields>
| >         </asp:DetailsView>
| >     </div>
| >     </form>
| > </body>
| > </html>
| > =======================
| >
| > 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.)
| >
| >
| >
| >
| >
| >
| >
| > --------------------
| > | Thread-Topic: Itemtemplace and many to one dropdown example wanted
| > | thread-index: AcYeKy7odVEPNOMCTeO27jfTJ/6shA==
| > | X-WBNR-Posting-Host: 65.35.95.187
| > | From: "=?Utf-8?B?VGRhclRkYXI=?=" <Tdar@noemail.nospam>
| > | Subject: Itemtemplace and many to one dropdown example wanted
| > | Date: Fri, 20 Jan 2006 17:37:04 -0800
| > | Lines: 14
| > | Message-ID: <DB561767-E612-4C0E-A000-91321BDF2***@microsoft.com>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > |     charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Show quoteHide quote
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.webcontrols:32702
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| > |
| > | Where can i find an expample of a item template that does the
following
| > |
| > | example of detailsview
| > |
| > |
| > | name:  Jack
| > | City:   2342
| > | State:  1
| > |
| > |
| > | I want to change the city field I assume using Itemtemplate, and have
| > | it link to a city table(another table) as a dropdown to display the
city
| > | name. 
| > |
| > |
| >
| >
|
Author
24 Jan 2006 5:24 PM
TdarTdar
Not sure how to answer your question but in the detailsview they will should
always be in the same postition of course that depends on what you are going
to tell me is the best way to go about this in asp.net 2.

here is the code


<%@ Page Language="VB" MasterPageFile="~/Site.master"
AutoEventWireup="false" CodeFile="ShowShipDetails.aspx.vb"
Inherits="Shipping_PreparePackage_ShowShipDetails" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
     <asp:DetailsView ID="DetailsView1" runat="server"
AutoGenerateRows="False"
        DataKeyNames="ShipKey" DataSourceID="ObjectDataSource1"
Height="50px" Width="275px">
        <Fields>
            <asp:BoundField DataField="ShipKey" HeaderText="ShipKey"
SortExpression="ShipKey" />
            <asp:BoundField DataField="DBMANTransNumber"
HeaderText="Transaction Number" SortExpression="DBMANTransNumber" />
            <asp:TemplateField HeaderText="User Name" SortExpression="UserId">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList2" runat="server"
DataSourceID="SqlDataSource2"
                        DataTextField="UserName" DataValueField="UserId"
Enabled="False" SelectedValue='<%# Bind("UserId") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:DropDownList ID="DropDownList9" runat="server"
DataSourceID="SqlDataSource2"
                        DataTextField="UserName" DataValueField="UserId"
SelectedValue='<%# Bind("UserId") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource2"
                        DataTextField="UserName" DataValueField="UserId"
Enabled="False" SelectedValue='<%# Bind("UserId") %>'>
                    </asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CheckBoxField DataField="SignatureReq"
HeaderText="Signature Required?" SortExpression="SignatureReq" />
            <asp:BoundField DataField="ShiptoCompany" HeaderText="Company"
SortExpression="ShiptoCompany" />
            <asp:BoundField DataField="ShiptoName" HeaderText="Name"
SortExpression="ShiptoName" />
            <asp:BoundField DataField="ShipToAddress" HeaderText="Address"
SortExpression="ShipToAddress" />
            <asp:BoundField DataField="ShipToAddress2" HeaderText="Address2"
SortExpression="ShipToAddress2" />
            <asp:TemplateField HeaderText="City" SortExpression="ShipCity">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList4" runat="server"
DataSourceID="SqlDataSource1"
                        DataTextField="CITY" DataValueField="CityKey"
SelectedValue='<%# Bind("ShipCity") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%#
Bind("ShipCity") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:DropDownList ID="DropDownList3" runat="server"
DataSourceID="SqlDataSource1"
                        DataTextField="CITY" DataValueField="CityKey"
Enabled="False" SelectedValue='<%# Bind("ShipCity") %>'>
                    </asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="State" SortExpression="ShipState">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList6" runat="server"
DataSourceID="SqlDataSource3"
                        DataTextField="StateName" DataValueField="StateKey"
Enabled="False" SelectedValue='<%# Bind("ShipState") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox4" runat="server" Text='<%#
Bind("ShipState") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:DropDownList ID="DropDownList5" runat="server"
DataSourceID="SqlDataSource3"
                        DataTextField="StateName" DataValueField="StateKey"
Enabled="False" SelectedValue='<%# Bind("ShipState") %>'>
                    </asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="ZipCode" HeaderText="Zip Code"
SortExpression="ZipCode" />
            <asp:TemplateField HeaderText="Country"
SortExpression="ShipCountry">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList8" runat="server"
DataSourceID="SqlDataSource4"
                        DataTextField="Country" DataValueField="CountryKey"
Enabled="False" SelectedValue='<%# Bind("ShipCountry") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%#
Bind("ShipCountry") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:DropDownList ID="DropDownList7" runat="server"
DataSourceID="SqlDataSource4"
                        DataTextField="Country" DataValueField="CountryKey"
Enabled="False" SelectedValue='<%# Bind("ShipCountry") %>'>
                    </asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ShowEditButton="True" />
        </Fields>
    </asp:DetailsView>
    <br />
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DataObjectTypeName=""
        DeleteMethod="Delete" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetData"
        TypeName="ShippingTableAdapters.OrderShipRecordTableAdapter"
UpdateMethod="Update">
        <UpdateParameters>
            <asp:Parameter Name="ShipKey" Type="Object" />
            <asp:Parameter Name="DBMANTransNumber" Type="String" />
            <asp:Parameter Name="UserId" Type="Object" />
            <asp:Parameter Name="SignatureReq" Type="Boolean" />
            <asp:Parameter Name="ShiptoCompany" Type="String" />
            <asp:Parameter Name="ShiptoName" Type="String" />
            <asp:Parameter Name="ShipToAddress" Type="String" />
            <asp:Parameter Name="ShipToAddress2" Type="String" />
            <asp:Parameter Name="ShipCity" Type="Int32" />
            <asp:Parameter Name="ShipCountry" Type="Int32" />
            <asp:Parameter Name="ShipState" Type="Int32" />
            <asp:Parameter Name="ZipCode" Type="String" />
            <asp:Parameter Name="Original_ShipKey" Type="Object" />
        </UpdateParameters>
        <SelectParameters>
            <asp:QueryStringParameter DefaultValue="-1" Name="ShipKey"
QueryStringField="ShipKey"
                Type="Object" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
        SelectCommand="SELECT [CityKey], [CITY], [StateKey] FROM [CITY]
Order by [City]" ></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$
ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
        SelectCommand="SELECT [StateKey], [StateName], [StateCode] FROM
[State] Order by [StateName]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$
ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
        SelectCommand="SELECT [UserId], [UserName] FROM [vw_aspnet_Users]
Order by [UserName]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource4" runat="server"
ConnectionString="<%$
ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
        SelectCommand="SELECT [CountryKey], [Country], [CountryCode] FROM
[Country] Order by [Country]"></asp:SqlDataSource>
</asp:Content>



Show quoteHide quote
"Steven Cheng[MSFT]" wrote:

> Thanks for your response Tdar,
>
> So your actual scenario is a bit more complex than I've expected.  As you
> mentioned:
>
> ====================
>  but how to a change one dropdown contents based on anothers current
> selection.
> =======================
>
> do you mean that there is another dropdownlist control(state info) which is
> used as filter of the City dropdownlist? If so, I think how to bind the
> dropdownlists depend on their relationship in the control collection. Are
> they put in the same parent control (a certain column in
> GridView/DetailsView or ....)? 
>
> Please feel free to let me know if there's anything I misunderstood.
>
> 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.)
>
> --------------------
> | Thread-Topic: Itemtemplace and many to one dropdown example wanted
> | thread-index: AcYgRZOzuS1EF2bwSpGIUCSqYZPYaQ==
> | X-WBNR-Posting-Host: 24.73.223.27
> | From: "=?Utf-8?B?VGRhclRkYXI=?=" <Tdar@noemail.nospam>
> | References:  <DB561767-E612-4C0E-A000-91321BDF2***@microsoft.com>
> <d0xSqF$HGHA.3***@TK2MSFTNGXA02.phx.gbl>
> | Subject: RE: Itemtemplace and many to one dropdown example wanted
> | Date: Mon, 23 Jan 2006 09:51:02 -0800
> | Lines: 172
> | Message-ID: <77EA8A99-ADF2-41D9-BEC3-75547BDB0***@microsoft.com>
> | MIME-Version: 1.0
> | Content-Type: text/plain;
> |     charset="Utf-8"
> | Content-Transfer-Encoding: 7bit
> | X-Newsreader: Microsoft CDO for Windows 2000
> | Content-Class: urn:content-classes:message
> | Importance: normal
> | Priority: normal
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
> | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
> | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
> | Xref: TK2MSFTNGXA02.phx.gbl
> microsoft.public.dotnet.framework.aspnet.webcontrols:32750
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
> |
> | Hi,
> |  Thanks that helped, but how to a change one dropdown contents based on
> | anothers current selection.
> |
> | as in selected state is "FL"
> |
> | so the cities dropdown in edit mode should only show "Citys" in "FL"
> |
> | I tried this but get an error:
> | <asp:SqlDataSource ID="SqlDataSource3" runat="server"
> ConnectionString="<%$
> | ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
> |         SelectCommand="SELECT [StateKey], [StateName], [StateCode] FROM
> | [State] where StateKey = <%# Bind("StateKey") %> Order by
> | [StateName]"></asp:SqlDataSource>
> |
> | I guess the bind statement is not valid at that time of form loading.
> |
> | Tdar
> |
> |
> |
> | "Steven Cheng[MSFT]" wrote:
> |
> | > Hi Tdar,
> | >
> | > Welcome.
> | > Regarding on the question you mentioned, do you mean that you want to
> | > display one of the column in DetailsView as a DropDownList and the
> | > dropdownlist's items will be filled by data retrieved from another
> database
> | > table?
> | >
> | > If so, a simple means is add an another DataSource control which
> connect to
> | > the data table that contains the DropDownList's items data....  Then,
> in
> | > our main DataBound  control(DetailsView?), we add a dropdownlist and
> set
> | > its datasourceID to the new datasource control and bind its
> selectedValue
> | > to the original databound value ......
> | >
> | > To make it clear, here is a simple example which display the Product
> | > table's data in a DetailsView control, and it contains one column which
> | > display the Category through a DropDownList....
> | >
> | > ==========aspx=============
> | > <html xmlns="http://www.w3.org/1999/xhtml" >
> | > <head runat="server">
> | >     <title>Untitled Page</title>
> | > </head>
> | > <body>
> | >     <form id="form1" runat="server">
> | >     <div>
> | >                <asp:SqlDataSource ID="SqlDataSource1" runat="server"
> | > ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
> | >             SelectCommand="SELECT [ProductID], [ProductName],
> [CategoryID]
> | > FROM [Products]" DeleteCommand="DELETE FROM [Products] WHERE
> [ProductID] =
> | > @ProductID" InsertCommand="INSERT INTO [Products] ([ProductName],
> | > [CategoryID]) VALUES (@ProductName, @CategoryID)" UpdateCommand="UPDATE
> | > [Products] SET [ProductName] = @ProductName, [CategoryID] = @CategoryID
> | > WHERE [ProductID] = @ProductID">
> | >             <DeleteParameters>
> | >                 <asp:Parameter Name="ProductID" Type="Int32" />
> | >             </DeleteParameters>
> | >             <UpdateParameters>
> | >                 <asp:Parameter Name="ProductName" Type="String" />
> | >                 <asp:Parameter Name="CategoryID" Type="Int32" />
> | >                 <asp:Parameter Name="ProductID" Type="Int32" />
> | >             </UpdateParameters>
> | >             <InsertParameters>
> | >                 <asp:Parameter Name="ProductName" Type="String" />
> | >                 <asp:Parameter Name="CategoryID" Type="Int32" />
> | >             </InsertParameters>
> | >         </asp:SqlDataSource>
> | >         <asp:SqlDataSource ID="SqlDataSource2" runat="server"
> | > ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
> | >             SelectCommand="SELECT [CategoryID], [CategoryName] FROM
> | > [Categories]"></asp:SqlDataSource>
> | >         <asp:DetailsView ID="DetailsView1" runat="server"
> | > AutoGenerateRows="False" DataKeyNames="ProductID"
> | >             DataSourceID="SqlDataSource1" Height="50px" Width="125px"
> | > AllowPaging="True">
> | >             <Fields>
> | >                 <asp:BoundField DataField="ProductID"
> | > HeaderText="ProductID" InsertVisible="False"
> | >                     ReadOnly="True" SortExpression="ProductID" />
> | >                 <asp:BoundField DataField="ProductName"
> | > HeaderText="ProductName" SortExpression="ProductName" />
> | >                 <asp:TemplateField HeaderText="CategoryID"
> | > SortExpression="CategoryID">
> | >                     <EditItemTemplate>
> | >                          <asp:DropDownList ID="DropDownList1"
> | > runat="server" DataSourceID="SqlDataSource2"
> | >                             DataTextField="CategoryName"
> | > DataValueField="CategoryID" SelectedValue='<%# Bind("CategoryID") %>'>
> | >                         </asp:DropDownList>
> | >                     </EditItemTemplate>
> | >                     <InsertItemTemplate>
> | >                         <asp:TextBox ID="TextBox1" runat="server"
> Text='<%#
> | > Bind("CategoryID") %>'></asp:TextBox>
> | >                     </InsertItemTemplate>
> | >                     <ItemTemplate>
> | >                          <asp:DropDownList ID="DropDownList2"
> | > runat="server" DataSourceID="SqlDataSource2"
> | >                             DataTextField="CategoryName"
> | > DataValueField="CategoryID" Enabled="False" SelectedValue='<%#
> | > Bind("CategoryID") %>'>
> | >                         </asp:DropDownList>
> | >                     </ItemTemplate>
> | >                 </asp:TemplateField>
> | >                 <asp:CommandField ShowEditButton="True" />
> | >             </Fields>
> | >         </asp:DetailsView>
> | >     </div>
> | >     </form>
> | > </body>
> | > </html>
> | > =======================
> | >
> | > 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.)
> | >
> | >
> | >
> | >
> | >
> | >
> | >
> | > --------------------
> | > | Thread-Topic: Itemtemplace and many to one dropdown example wanted
> | > | thread-index: AcYeKy7odVEPNOMCTeO27jfTJ/6shA==
> | > | X-WBNR-Posting-Host: 65.35.95.187
> | > | From: "=?Utf-8?B?VGRhclRkYXI=?=" <Tdar@noemail.nospam>
> | > | Subject: Itemtemplace and many to one dropdown example wanted
> | > | Date: Fri, 20 Jan 2006 17:37:04 -0800
> | > | Lines: 14
> | > | Message-ID: <DB561767-E612-4C0E-A000-91321BDF2***@microsoft.com>
> | > | MIME-Version: 1.0
> | > | Content-Type: text/plain;
> | > |     charset="Utf-8"
> | > | Content-Transfer-Encoding: 7bit
> | > | X-Newsreader: Microsoft CDO for Windows 2000
> | > | Content-Class: urn:content-classes:message
> | > | Importance: normal
> | > | Priority: normal
> | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
> | > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
> | > | Path:
> TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
> | > | Xref: TK2MSFTNGXA02.phx.gbl
> | > microsoft.public.dotnet.framework.aspnet.webcontrols:32702
> | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
> | > |
> | > | Where can i find an expample of a item template that does the
> following
> | > |
> | > | example of detailsview
> | > |
> | > |
> | > | name:  Jack
> | > | City:   2342
> | > | State:  1
> | > |
> | > |
> | > | I want to change the city field I assume using Itemtemplate, and have
> | > | it link to a city table(another table) as a dropdown to display the
> city
> | > | name. 
> | > |
> | > |
> | >
> | >
> |
>
>
Author
25 Jan 2006 11:52 AM
Steven Cheng[MSFT]
Hi Tdar,

Since I haven't such database tables on hand, I haven't tested on it.
However, based on my understanding, I think you can consider put the
additional datasource control(populate the dropdownlist) in the
EditTemplate and provide a select paramters for filtering...

Then, the parameter's source is Control parameter. And we need to add an
additional control , for example, a Label (the visible set to false) and
bind its Text property to the main datasource item's  filtering column (for
your case it's the "State" ....). After that, we can map the Control
Paramter to that label.....

Hope this make it clear. If there's anything unclear, please feel free to
post here.

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.)


--------------------
| Thread-Topic: Itemtemplace and many to one dropdown example wanted
| thread-index: AcYhCvvu8ioH0gHQQneCkODBfJlbKQ==
| X-WBNR-Posting-Host: 24.73.223.27
| From: "=?Utf-8?B?VGRhclRkYXI=?=" <Tdar@noemail.nospam>
| References:  <DB561767-E612-4C0E-A000-91321BDF2***@microsoft.com>
<d0xSqF$HGHA.3***@TK2MSFTNGXA02.phx.gbl>
<77EA8A99-ADF2-41D9-BEC3-75547BDB0***@microsoft.com>
<yQoe$hLIGHA.3***@TK2MSFTNGXA02.phx.gbl>
Show quoteHide quote
| Subject: RE: Itemtemplace and many to one dropdown example wanted
| Date: Tue, 24 Jan 2006 09:24:08 -0800
| Lines: 415
| Message-ID: <FDD8CF80-536E-42A7-B520-B2924B376***@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
|     charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:32773
Show quoteHide quote
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Not sure how to answer your question but in the detailsview they will
should
| always be in the same postition of course that depends on what you are
going
| to tell me is the best way to go about this in asp.net 2.
|
| here is the code
|
|
| <%@ Page Language="VB" MasterPageFile="~/Site.master"
| AutoEventWireup="false" CodeFile="ShowShipDetails.aspx.vb"
| Inherits="Shipping_PreparePackage_ShowShipDetails" title="Untitled Page"
%>
| <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
| Runat="Server">
|      <asp:DetailsView ID="DetailsView1" runat="server"
| AutoGenerateRows="False"
|         DataKeyNames="ShipKey" DataSourceID="ObjectDataSource1"
| Height="50px" Width="275px">
|         <Fields>
|             <asp:BoundField DataField="ShipKey" HeaderText="ShipKey"
| SortExpression="ShipKey" />
|             <asp:BoundField DataField="DBMANTransNumber"
| HeaderText="Transaction Number" SortExpression="DBMANTransNumber" />
|             <asp:TemplateField HeaderText="User Name"
SortExpression="UserId">
Show quoteHide quote
|                 <EditItemTemplate>
|                     <asp:DropDownList ID="DropDownList2" runat="server"
| DataSourceID="SqlDataSource2"
|                         DataTextField="UserName" DataValueField="UserId"
| Enabled="False" SelectedValue='<%# Bind("UserId") %>'>
|                     </asp:DropDownList>
|                 </EditItemTemplate>
|                 <InsertItemTemplate>
|                     <asp:DropDownList ID="DropDownList9" runat="server"
| DataSourceID="SqlDataSource2"
|                         DataTextField="UserName" DataValueField="UserId"
| SelectedValue='<%# Bind("UserId") %>'>
|                     </asp:DropDownList>
|                 </InsertItemTemplate>
|                 <ItemTemplate>
|                     <asp:DropDownList ID="DropDownList1" runat="server"
| DataSourceID="SqlDataSource2"
|                         DataTextField="UserName" DataValueField="UserId"
| Enabled="False" SelectedValue='<%# Bind("UserId") %>'>
|                     </asp:DropDownList>
|                 </ItemTemplate>
|             </asp:TemplateField>
|             <asp:CheckBoxField DataField="SignatureReq"
| HeaderText="Signature Required?" SortExpression="SignatureReq" />
|             <asp:BoundField DataField="ShiptoCompany"
HeaderText="Company"
| SortExpression="ShiptoCompany" />
|             <asp:BoundField DataField="ShiptoName" HeaderText="Name"
| SortExpression="ShiptoName" />
|             <asp:BoundField DataField="ShipToAddress"
HeaderText="Address"
| SortExpression="ShipToAddress" />
|             <asp:BoundField DataField="ShipToAddress2"
HeaderText="Address2"
| SortExpression="ShipToAddress2" />
|             <asp:TemplateField HeaderText="City"
SortExpression="ShipCity">
Show quoteHide quote
|                 <EditItemTemplate>
|                     <asp:DropDownList ID="DropDownList4" runat="server"
| DataSourceID="SqlDataSource1"
|                         DataTextField="CITY" DataValueField="CityKey"
| SelectedValue='<%# Bind("ShipCity") %>'>
|                     </asp:DropDownList>
|                 </EditItemTemplate>
|                 <InsertItemTemplate>
|                     <asp:TextBox ID="TextBox2" runat="server" Text='<%#
| Bind("ShipCity") %>'></asp:TextBox>
|                 </InsertItemTemplate>
|                 <ItemTemplate>
|                     <asp:DropDownList ID="DropDownList3" runat="server"
| DataSourceID="SqlDataSource1"
|                         DataTextField="CITY" DataValueField="CityKey"
| Enabled="False" SelectedValue='<%# Bind("ShipCity") %>'>
|                     </asp:DropDownList>
|                 </ItemTemplate>
|             </asp:TemplateField>
|             <asp:TemplateField HeaderText="State"
SortExpression="ShipState">
Show quoteHide quote
|                 <EditItemTemplate>
|                     <asp:DropDownList ID="DropDownList6" runat="server"
| DataSourceID="SqlDataSource3"
|                         DataTextField="StateName"
DataValueField="StateKey"
| Enabled="False" SelectedValue='<%# Bind("ShipState") %>'>
|                     </asp:DropDownList>
|                 </EditItemTemplate>
|                 <InsertItemTemplate>
|                     <asp:TextBox ID="TextBox4" runat="server" Text='<%#
| Bind("ShipState") %>'></asp:TextBox>
|                 </InsertItemTemplate>
|                 <ItemTemplate>
|                     <asp:DropDownList ID="DropDownList5" runat="server"
| DataSourceID="SqlDataSource3"
|                         DataTextField="StateName"
DataValueField="StateKey"
| Enabled="False" SelectedValue='<%# Bind("ShipState") %>'>
|                     </asp:DropDownList>
|                 </ItemTemplate>
|             </asp:TemplateField>
|             <asp:BoundField DataField="ZipCode" HeaderText="Zip Code"
| SortExpression="ZipCode" />
|             <asp:TemplateField HeaderText="Country"
| SortExpression="ShipCountry">
|                 <EditItemTemplate>
|                     <asp:DropDownList ID="DropDownList8" runat="server"
| DataSourceID="SqlDataSource4"
|                         DataTextField="Country"
DataValueField="CountryKey"
| Enabled="False" SelectedValue='<%# Bind("ShipCountry") %>'>
|                     </asp:DropDownList>
|                 </EditItemTemplate>
|                 <InsertItemTemplate>
|                     <asp:TextBox ID="TextBox3" runat="server" Text='<%#
| Bind("ShipCountry") %>'></asp:TextBox>
|                 </InsertItemTemplate>
|                 <ItemTemplate>
|                     <asp:DropDownList ID="DropDownList7" runat="server"
| DataSourceID="SqlDataSource4"
|                         DataTextField="Country"
DataValueField="CountryKey"
| Enabled="False" SelectedValue='<%# Bind("ShipCountry") %>'>
|                     </asp:DropDownList>
|                 </ItemTemplate>
|             </asp:TemplateField>
|             <asp:CommandField ShowEditButton="True" />
|         </Fields>
|     </asp:DetailsView>
|     <br />
|     <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
| DataObjectTypeName=""
|         DeleteMethod="Delete"
OldValuesParameterFormatString="original_{0}"
Show quoteHide quote
| SelectMethod="GetData"
|         TypeName="ShippingTableAdapters.OrderShipRecordTableAdapter"
| UpdateMethod="Update">
|         <UpdateParameters>
|             <asp:Parameter Name="ShipKey" Type="Object" />
|             <asp:Parameter Name="DBMANTransNumber" Type="String" />
|             <asp:Parameter Name="UserId" Type="Object" />
|             <asp:Parameter Name="SignatureReq" Type="Boolean" />
|             <asp:Parameter Name="ShiptoCompany" Type="String" />
|             <asp:Parameter Name="ShiptoName" Type="String" />
|             <asp:Parameter Name="ShipToAddress" Type="String" />
|             <asp:Parameter Name="ShipToAddress2" Type="String" />
|             <asp:Parameter Name="ShipCity" Type="Int32" />
|             <asp:Parameter Name="ShipCountry" Type="Int32" />
|             <asp:Parameter Name="ShipState" Type="Int32" />
|             <asp:Parameter Name="ZipCode" Type="String" />
|             <asp:Parameter Name="Original_ShipKey" Type="Object" />
|         </UpdateParameters>
|         <SelectParameters>
|             <asp:QueryStringParameter DefaultValue="-1" Name="ShipKey"
| QueryStringField="ShipKey"
|                 Type="Object" />
|         </SelectParameters>
|     </asp:ObjectDataSource>
|     <asp:SqlDataSource ID="SqlDataSource1" runat="server"
| ConnectionString="<%$
| ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
|         SelectCommand="SELECT [CityKey], [CITY], [StateKey] FROM [CITY]
| Order by [City]" ></asp:SqlDataSource>
|     <asp:SqlDataSource ID="SqlDataSource3" runat="server"
| ConnectionString="<%$
| ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
|         SelectCommand="SELECT [StateKey], [StateName], [StateCode] FROM
| [State] Order by [StateName]"></asp:SqlDataSource>
|     <asp:SqlDataSource ID="SqlDataSource2" runat="server"
| ConnectionString="<%$
| ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
|         SelectCommand="SELECT [UserId], [UserName] FROM [vw_aspnet_Users]
| Order by [UserName]"></asp:SqlDataSource>
|     <asp:SqlDataSource ID="SqlDataSource4" runat="server"
| ConnectionString="<%$
| ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
|         SelectCommand="SELECT [CountryKey], [Country], [CountryCode] FROM
| [Country] Order by [Country]"></asp:SqlDataSource>
| </asp:Content>
|
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Thanks for your response Tdar,
| >
| > So your actual scenario is a bit more complex than I've expected.  As
you
| > mentioned:
| >
| > ====================
| >  but how to a change one dropdown contents based on anothers current
| > selection.
| > =======================
| >
| > do you mean that there is another dropdownlist control(state info)
which is
| > used as filter of the City dropdownlist? If so, I think how to bind the
| > dropdownlists depend on their relationship in the control collection.
Are
| > they put in the same parent control (a certain column in
| > GridView/DetailsView or ....)? 
| >
| > Please feel free to let me know if there's anything I misunderstood.
| >
| > 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.)
| >
| > --------------------
| > | Thread-Topic: Itemtemplace and many to one dropdown example wanted
| > | thread-index: AcYgRZOzuS1EF2bwSpGIUCSqYZPYaQ==
| > | X-WBNR-Posting-Host: 24.73.223.27
| > | From: "=?Utf-8?B?VGRhclRkYXI=?=" <Tdar@noemail.nospam>
| > | References:  <DB561767-E612-4C0E-A000-91321BDF2***@microsoft.com>
| > <d0xSqF$HGHA.3***@TK2MSFTNGXA02.phx.gbl>
| > | Subject: RE: Itemtemplace and many to one dropdown example wanted
| > | Date: Mon, 23 Jan 2006 09:51:02 -0800
| > | Lines: 172
| > | Message-ID: <77EA8A99-ADF2-41D9-BEC3-75547BDB0***@microsoft.com>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > |     charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.webcontrols:32750
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| > |
| > | Hi,
| > |  Thanks that helped, but how to a change one dropdown contents based
on
| > | anothers current selection.
| > |
| > | as in selected state is "FL"
| > |
| > | so the cities dropdown in edit mode should only show "Citys" in "FL"
| > |
| > | I tried this but get an error:
| > | <asp:SqlDataSource ID="SqlDataSource3" runat="server"
| > ConnectionString="<%$
| > | ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
| > |         SelectCommand="SELECT [StateKey], [StateName], [StateCode]
FROM
| > | [State] where StateKey = <%# Bind("StateKey") %> Order by
| > | [StateName]"></asp:SqlDataSource>
| > |
| > | I guess the bind statement is not valid at that time of form loading.
| > |
| > | Tdar
| > |
| > |
| > |
| > | "Steven Cheng[MSFT]" wrote:
| > |
| > | > Hi Tdar,
| > | >
| > | > Welcome.
| > | > Regarding on the question you mentioned, do you mean that you want
to
| > | > display one of the column in DetailsView as a DropDownList and the
| > | > dropdownlist's items will be filled by data retrieved from another
| > database
| > | > table?
| > | >
| > | > If so, a simple means is add an another DataSource control which
| > connect to
| > | > the data table that contains the DropDownList's items data.... 
Then,
| > in
| > | > our main DataBound  control(DetailsView?), we add a dropdownlist
and
| > set
| > | > its datasourceID to the new datasource control and bind its
| > selectedValue
| > | > to the original databound value ......
| > | >
| > | > To make it clear, here is a simple example which display the
Product
| > | > table's data in a DetailsView control, and it contains one column
which
| > | > display the Category through a DropDownList....
| > | >
| > | > ==========aspx=============
| > | > <html xmlns="http://www.w3.org/1999/xhtml" >
| > | > <head runat="server">
| > | >     <title>Untitled Page</title>
| > | > </head>
| > | > <body>
| > | >     <form id="form1" runat="server">
| > | >     <div>
| > | >                <asp:SqlDataSource ID="SqlDataSource1"
runat="server"
| > | > ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString
%>"
| > | >             SelectCommand="SELECT [ProductID], [ProductName],
| > [CategoryID]
| > | > FROM [Products]" DeleteCommand="DELETE FROM [Products] WHERE
| > [ProductID] =
| > | > @ProductID" InsertCommand="INSERT INTO [Products] ([ProductName],
| > | > [CategoryID]) VALUES (@ProductName, @CategoryID)"
UpdateCommand="UPDATE
| > | > [Products] SET [ProductName] = @ProductName, [CategoryID] =
@CategoryID
| > | > WHERE [ProductID] = @ProductID">
| > | >             <DeleteParameters>
| > | >                 <asp:Parameter Name="ProductID" Type="Int32" />
| > | >             </DeleteParameters>
| > | >             <UpdateParameters>
| > | >                 <asp:Parameter Name="ProductName" Type="String" />
| > | >                 <asp:Parameter Name="CategoryID" Type="Int32" />
| > | >                 <asp:Parameter Name="ProductID" Type="Int32" />
| > | >             </UpdateParameters>
| > | >             <InsertParameters>
| > | >                 <asp:Parameter Name="ProductName" Type="String" />
| > | >                 <asp:Parameter Name="CategoryID" Type="Int32" />
| > | >             </InsertParameters>
| > | >         </asp:SqlDataSource>
| > | >         <asp:SqlDataSource ID="SqlDataSource2" runat="server"
| > | > ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString
%>"
| > | >             SelectCommand="SELECT [CategoryID], [CategoryName] FROM
| > | > [Categories]"></asp:SqlDataSource>
| > | >         <asp:DetailsView ID="DetailsView1" runat="server"
| > | > AutoGenerateRows="False" DataKeyNames="ProductID"
| > | >             DataSourceID="SqlDataSource1" Height="50px"
Width="125px"
| > | > AllowPaging="True">
| > | >             <Fields>
| > | >                 <asp:BoundField DataField="ProductID"
| > | > HeaderText="ProductID" InsertVisible="False"
| > | >                     ReadOnly="True" SortExpression="ProductID" />
| > | >                 <asp:BoundField DataField="ProductName"
| > | > HeaderText="ProductName" SortExpression="ProductName" />
| > | >                 <asp:TemplateField HeaderText="CategoryID"
| > | > SortExpression="CategoryID">
| > | >                     <EditItemTemplate>
| > | >                          <asp:DropDownList ID="DropDownList1"
| > | > runat="server" DataSourceID="SqlDataSource2"
| > | >                             DataTextField="CategoryName"
| > | > DataValueField="CategoryID" SelectedValue='<%# Bind("CategoryID")
%>'>
| > | >                         </asp:DropDownList>
| > | >                     </EditItemTemplate>
| > | >                     <InsertItemTemplate>
| > | >                         <asp:TextBox ID="TextBox1" runat="server"
| > Text='<%#
| > | > Bind("CategoryID") %>'></asp:TextBox>
| > | >                     </InsertItemTemplate>
| > | >                     <ItemTemplate>
| > | >                          <asp:DropDownList ID="DropDownList2"
| > | > runat="server" DataSourceID="SqlDataSource2"
| > | >                             DataTextField="CategoryName"
| > | > DataValueField="CategoryID" Enabled="False" SelectedValue='<%#
| > | > Bind("CategoryID") %>'>
| > | >                         </asp:DropDownList>
| > | >                     </ItemTemplate>
| > | >                 </asp:TemplateField>
| > | >                 <asp:CommandField ShowEditButton="True" />
| > | >             </Fields>
| > | >         </asp:DetailsView>
| > | >     </div>
| > | >     </form>
| > | > </body>
| > | > </html>
| > | > =======================
| > | >
| > | > 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.)
| > | >
| > | >
| > | >
| > | >
| > | >
| > | >
| > | >
| > | > --------------------
| > | > | Thread-Topic: Itemtemplace and many to one dropdown example wanted
| > | > | thread-index: AcYeKy7odVEPNOMCTeO27jfTJ/6shA==
| > | > | X-WBNR-Posting-Host: 65.35.95.187
| > | > | From: "=?Utf-8?B?VGRhclRkYXI=?=" <Tdar@noemail.nospam>
| > | > | Subject: Itemtemplace and many to one dropdown example wanted
| > | > | Date: Fri, 20 Jan 2006 17:37:04 -0800
| > | > | Lines: 14
| > | > | Message-ID: <DB561767-E612-4C0E-A000-91321BDF2***@microsoft.com>
| > | > | MIME-Version: 1.0
| > | > | Content-Type: text/plain;
| > | > |     charset="Utf-8"
| > | > | Content-Transfer-Encoding: 7bit
| > | > | X-Newsreader: Microsoft CDO for Windows 2000
| > | > | Content-Class: urn:content-classes:message
| > | > | Importance: normal
| > | > | Priority: normal
| > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | > | Path:
| > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | > | Xref: TK2MSFTNGXA02.phx.gbl
| > | > microsoft.public.dotnet.framework.aspnet.webcontrols:32702
| > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | > |
| > | > | Where can i find an expample of a item template that does the
| > following
| > | > |
| > | > | example of detailsview
| > | > |
| > | > |
| > | > | name:  Jack
| > | > | City:   2342
| > | > | State:  1
| > | > |
| > | > |
| > | > | I want to change the city field I assume using Itemtemplate, and
have
| > | > | it link to a city table(another table) as a dropdown to display
the
| > city
| > | > | name. 
| > | > |
| > | > |
| > | >
| > | >
| > |
| >
| >
|
Author
25 Jan 2006 4:05 PM
TdarTdar
Wow, thats cool, it works fine. I thank you much for helping me get
past these learning curves.



Show quoteHide quote
"Steven Cheng[MSFT]" wrote:

> Hi Tdar,
>
> Since I haven't such database tables on hand, I haven't tested on it.
> However, based on my understanding, I think you can consider put the
> additional datasource control(populate the dropdownlist) in the
> EditTemplate and provide a select paramters for filtering...
>
> Then, the parameter's source is Control parameter. And we need to add an
> additional control , for example, a Label (the visible set to false) and
> bind its Text property to the main datasource item's  filtering column (for
> your case it's the "State" ....). After that, we can map the Control
> Paramter to that label.....
>
> Hope this make it clear. If there's anything unclear, please feel free to
> post here.
>
> 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.)
>
>
> --------------------
> | Thread-Topic: Itemtemplace and many to one dropdown example wanted
> | thread-index: AcYhCvvu8ioH0gHQQneCkODBfJlbKQ==
> | X-WBNR-Posting-Host: 24.73.223.27
> | From: "=?Utf-8?B?VGRhclRkYXI=?=" <Tdar@noemail.nospam>
> | References:  <DB561767-E612-4C0E-A000-91321BDF2***@microsoft.com>
> <d0xSqF$HGHA.3***@TK2MSFTNGXA02.phx.gbl>
> <77EA8A99-ADF2-41D9-BEC3-75547BDB0***@microsoft.com>
> <yQoe$hLIGHA.3***@TK2MSFTNGXA02.phx.gbl>
> | Subject: RE: Itemtemplace and many to one dropdown example wanted
> | Date: Tue, 24 Jan 2006 09:24:08 -0800
> | Lines: 415
> | Message-ID: <FDD8CF80-536E-42A7-B520-B2924B376***@microsoft.com>
> | MIME-Version: 1.0
> | Content-Type: text/plain;
> |     charset="Utf-8"
> | Content-Transfer-Encoding: 7bit
> | X-Newsreader: Microsoft CDO for Windows 2000
> | Content-Class: urn:content-classes:message
> | Importance: normal
> | Priority: normal
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
> | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
> | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
> | Xref: TK2MSFTNGXA02.phx.gbl
> microsoft.public.dotnet.framework.aspnet.webcontrols:32773
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
> |
> | Not sure how to answer your question but in the detailsview they will
> should
> | always be in the same postition of course that depends on what you are
> going
> | to tell me is the best way to go about this in asp.net 2.
> |
> | here is the code
> |
> |
> | <%@ Page Language="VB" MasterPageFile="~/Site.master"
> | AutoEventWireup="false" CodeFile="ShowShipDetails.aspx.vb"
> | Inherits="Shipping_PreparePackage_ShowShipDetails" title="Untitled Page"
> %>
> | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
> | Runat="Server">
> |      <asp:DetailsView ID="DetailsView1" runat="server"
> | AutoGenerateRows="False"
> |         DataKeyNames="ShipKey" DataSourceID="ObjectDataSource1"
> | Height="50px" Width="275px">
> |         <Fields>
> |             <asp:BoundField DataField="ShipKey" HeaderText="ShipKey"
> | SortExpression="ShipKey" />
> |             <asp:BoundField DataField="DBMANTransNumber"
> | HeaderText="Transaction Number" SortExpression="DBMANTransNumber" />
> |             <asp:TemplateField HeaderText="User Name"
> SortExpression="UserId">
> |                 <EditItemTemplate>
> |                     <asp:DropDownList ID="DropDownList2" runat="server"
> | DataSourceID="SqlDataSource2"
> |                         DataTextField="UserName" DataValueField="UserId"
> | Enabled="False" SelectedValue='<%# Bind("UserId") %>'>
> |                     </asp:DropDownList>
> |                 </EditItemTemplate>
> |                 <InsertItemTemplate>
> |                     <asp:DropDownList ID="DropDownList9" runat="server"
> | DataSourceID="SqlDataSource2"
> |                         DataTextField="UserName" DataValueField="UserId"
> | SelectedValue='<%# Bind("UserId") %>'>
> |                     </asp:DropDownList>
> |                 </InsertItemTemplate>
> |                 <ItemTemplate>
> |                     <asp:DropDownList ID="DropDownList1" runat="server"
> | DataSourceID="SqlDataSource2"
> |                         DataTextField="UserName" DataValueField="UserId"
> | Enabled="False" SelectedValue='<%# Bind("UserId") %>'>
> |                     </asp:DropDownList>
> |                 </ItemTemplate>
> |             </asp:TemplateField>
> |             <asp:CheckBoxField DataField="SignatureReq"
> | HeaderText="Signature Required?" SortExpression="SignatureReq" />
> |             <asp:BoundField DataField="ShiptoCompany"
> HeaderText="Company"
> | SortExpression="ShiptoCompany" />
> |             <asp:BoundField DataField="ShiptoName" HeaderText="Name"
> | SortExpression="ShiptoName" />
> |             <asp:BoundField DataField="ShipToAddress"
> HeaderText="Address"
> | SortExpression="ShipToAddress" />
> |             <asp:BoundField DataField="ShipToAddress2"
> HeaderText="Address2"
> | SortExpression="ShipToAddress2" />
> |             <asp:TemplateField HeaderText="City"
> SortExpression="ShipCity">
> |                 <EditItemTemplate>
> |                     <asp:DropDownList ID="DropDownList4" runat="server"
> | DataSourceID="SqlDataSource1"
> |                         DataTextField="CITY" DataValueField="CityKey"
> | SelectedValue='<%# Bind("ShipCity") %>'>
> |                     </asp:DropDownList>
> |                 </EditItemTemplate>
> |                 <InsertItemTemplate>
> |                     <asp:TextBox ID="TextBox2" runat="server" Text='<%#
> | Bind("ShipCity") %>'></asp:TextBox>
> |                 </InsertItemTemplate>
> |                 <ItemTemplate>
> |                     <asp:DropDownList ID="DropDownList3" runat="server"
> | DataSourceID="SqlDataSource1"
> |                         DataTextField="CITY" DataValueField="CityKey"
> | Enabled="False" SelectedValue='<%# Bind("ShipCity") %>'>
> |                     </asp:DropDownList>
> |                 </ItemTemplate>
> |             </asp:TemplateField>
> |             <asp:TemplateField HeaderText="State"
> SortExpression="ShipState">
> |                 <EditItemTemplate>
> |                     <asp:DropDownList ID="DropDownList6" runat="server"
> | DataSourceID="SqlDataSource3"
> |                         DataTextField="StateName"
> DataValueField="StateKey"
> | Enabled="False" SelectedValue='<%# Bind("ShipState") %>'>
> |                     </asp:DropDownList>
> |                 </EditItemTemplate>
> |                 <InsertItemTemplate>
> |                     <asp:TextBox ID="TextBox4" runat="server" Text='<%#
> | Bind("ShipState") %>'></asp:TextBox>
> |                 </InsertItemTemplate>
> |                 <ItemTemplate>
> |                     <asp:DropDownList ID="DropDownList5" runat="server"
> | DataSourceID="SqlDataSource3"
> |                         DataTextField="StateName"
> DataValueField="StateKey"
> | Enabled="False" SelectedValue='<%# Bind("ShipState") %>'>
> |                     </asp:DropDownList>
> |                 </ItemTemplate>
> |             </asp:TemplateField>
> |             <asp:BoundField DataField="ZipCode" HeaderText="Zip Code"
> | SortExpression="ZipCode" />
> |             <asp:TemplateField HeaderText="Country"
> | SortExpression="ShipCountry">
> |                 <EditItemTemplate>
> |                     <asp:DropDownList ID="DropDownList8" runat="server"
> | DataSourceID="SqlDataSource4"
> |                         DataTextField="Country"
> DataValueField="CountryKey"
> | Enabled="False" SelectedValue='<%# Bind("ShipCountry") %>'>
> |                     </asp:DropDownList>
> |                 </EditItemTemplate>
> |                 <InsertItemTemplate>
> |                     <asp:TextBox ID="TextBox3" runat="server" Text='<%#
> | Bind("ShipCountry") %>'></asp:TextBox>
> |                 </InsertItemTemplate>
> |                 <ItemTemplate>
> |                     <asp:DropDownList ID="DropDownList7" runat="server"
> | DataSourceID="SqlDataSource4"
> |                         DataTextField="Country"
> DataValueField="CountryKey"
> | Enabled="False" SelectedValue='<%# Bind("ShipCountry") %>'>
> |                     </asp:DropDownList>
> |                 </ItemTemplate>
> |             </asp:TemplateField>
> |             <asp:CommandField ShowEditButton="True" />
> |         </Fields>
> |     </asp:DetailsView>
> |     <br />
> |     <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
> | DataObjectTypeName=""
> |         DeleteMethod="Delete"
> OldValuesParameterFormatString="original_{0}"
> | SelectMethod="GetData"
> |         TypeName="ShippingTableAdapters.OrderShipRecordTableAdapter"
> | UpdateMethod="Update">
> |         <UpdateParameters>
> |             <asp:Parameter Name="ShipKey" Type="Object" />
> |             <asp:Parameter Name="DBMANTransNumber" Type="String" />
> |             <asp:Parameter Name="UserId" Type="Object" />
> |             <asp:Parameter Name="SignatureReq" Type="Boolean" />
> |             <asp:Parameter Name="ShiptoCompany" Type="String" />
> |             <asp:Parameter Name="ShiptoName" Type="String" />
> |             <asp:Parameter Name="ShipToAddress" Type="String" />
> |             <asp:Parameter Name="ShipToAddress2" Type="String" />
> |             <asp:Parameter Name="ShipCity" Type="Int32" />
> |             <asp:Parameter Name="ShipCountry" Type="Int32" />
> |             <asp:Parameter Name="ShipState" Type="Int32" />
> |             <asp:Parameter Name="ZipCode" Type="String" />
> |             <asp:Parameter Name="Original_ShipKey" Type="Object" />
> |         </UpdateParameters>
> |         <SelectParameters>
> |             <asp:QueryStringParameter DefaultValue="-1" Name="ShipKey"
> | QueryStringField="ShipKey"
> |                 Type="Object" />
> |         </SelectParameters>
> |     </asp:ObjectDataSource>
> |     <asp:SqlDataSource ID="SqlDataSource1" runat="server"
> | ConnectionString="<%$
> | ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
> |         SelectCommand="SELECT [CityKey], [CITY], [StateKey] FROM [CITY]
> | Order by [City]" ></asp:SqlDataSource>
> |     <asp:SqlDataSource ID="SqlDataSource3" runat="server"
> | ConnectionString="<%$
> | ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
> |         SelectCommand="SELECT [StateKey], [StateName], [StateCode] FROM
> | [State] Order by [StateName]"></asp:SqlDataSource>
> |     <asp:SqlDataSource ID="SqlDataSource2" runat="server"
> | ConnectionString="<%$
> | ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
> |         SelectCommand="SELECT [UserId], [UserName] FROM [vw_aspnet_Users]
> | Order by [UserName]"></asp:SqlDataSource>
> |     <asp:SqlDataSource ID="SqlDataSource4" runat="server"
> | ConnectionString="<%$
> | ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
> |         SelectCommand="SELECT [CountryKey], [Country], [CountryCode] FROM
> | [Country] Order by [Country]"></asp:SqlDataSource>
> | </asp:Content>
> |
> |
> |
> | "Steven Cheng[MSFT]" wrote:
> |
> | > Thanks for your response Tdar,
> | >
> | > So your actual scenario is a bit more complex than I've expected.  As
> you
> | > mentioned:
> | >
> | > ====================
> | >  but how to a change one dropdown contents based on anothers current
> | > selection.
> | > =======================
> | >
> | > do you mean that there is another dropdownlist control(state info)
> which is
> | > used as filter of the City dropdownlist? If so, I think how to bind the
> | > dropdownlists depend on their relationship in the control collection.
> Are
> | > they put in the same parent control (a certain column in
> | > GridView/DetailsView or ....)? 
> | >
> | > Please feel free to let me know if there's anything I misunderstood.
> | >
> | > 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.)
> | >
> | > --------------------
> | > | Thread-Topic: Itemtemplace and many to one dropdown example wanted
> | > | thread-index: AcYgRZOzuS1EF2bwSpGIUCSqYZPYaQ==
> | > | X-WBNR-Posting-Host: 24.73.223.27
> | > | From: "=?Utf-8?B?VGRhclRkYXI=?=" <Tdar@noemail.nospam>
> | > | References:  <DB561767-E612-4C0E-A000-91321BDF2***@microsoft.com>
> | > <d0xSqF$HGHA.3***@TK2MSFTNGXA02.phx.gbl>
> | > | Subject: RE: Itemtemplace and many to one dropdown example wanted
> | > | Date: Mon, 23 Jan 2006 09:51:02 -0800
> | > | Lines: 172
> | > | Message-ID: <77EA8A99-ADF2-41D9-BEC3-75547BDB0***@microsoft.com>
> | > | MIME-Version: 1.0
> | > | Content-Type: text/plain;
> | > |     charset="Utf-8"
> | > | Content-Transfer-Encoding: 7bit
> | > | X-Newsreader: Microsoft CDO for Windows 2000
> | > | Content-Class: urn:content-classes:message
> | > | Importance: normal
> | > | Priority: normal
> | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
> | > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
> | > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
> | > | Xref: TK2MSFTNGXA02.phx.gbl
> | > microsoft.public.dotnet.framework.aspnet.webcontrols:32750
> | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
> | > |
Author
26 Jan 2006 1:46 AM
Steven Cheng[MSFT]
You're welcome Tdar,

Glad that it helps you.

Have a good day!

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: Itemtemplace and many to one dropdown example wanted
| thread-index: AcYhyRr49xL+6mSEQpKTeORU0A0XZw==
| X-WBNR-Posting-Host: 24.73.223.27
| From: "=?Utf-8?B?VGRhclRkYXI=?=" <Tdar@noemail.nospam>
| References:  <DB561767-E612-4C0E-A000-91321BDF2***@microsoft.com>
<d0xSqF$HGHA.3***@TK2MSFTNGXA02.phx.gbl>
<77EA8A99-ADF2-41D9-BEC3-75547BDB0***@microsoft.com>
<yQoe$hLIGHA.3***@TK2MSFTNGXA02.phx.gbl>
<FDD8CF80-536E-42A7-B520-B2924B376***@microsoft.com>
<nly4NXaIGHA.1***@TK2MSFTNGXA02.phx.gbl>
Show quoteHide quote
| Subject: RE: Itemtemplace and many to one dropdown example wanted
| Date: Wed, 25 Jan 2006 08:05:05 -0800
| Lines: 307
| Message-ID: <1B91488F-B247-46A5-B112-69CB920F3***@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
|     charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:32803
Show quoteHide quote
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Wow, thats cool, it works fine. I thank you much for helping me get
| past these learning curves.
|
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi Tdar,
| >
| > Since I haven't such database tables on hand, I haven't tested on it.
| > However, based on my understanding, I think you can consider put the
| > additional datasource control(populate the dropdownlist) in the
| > EditTemplate and provide a select paramters for filtering...
| >
| > Then, the parameter's source is Control parameter. And we need to add
an
| > additional control , for example, a Label (the visible set to false)
and
| > bind its Text property to the main datasource item's  filtering column
(for
| > your case it's the "State" ....). After that, we can map the Control
| > Paramter to that label.....
| >
| > Hope this make it clear. If there's anything unclear, please feel free
to
| > post here.
| >
| > 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.)
| >
| >
| > --------------------
| > | Thread-Topic: Itemtemplace and many to one dropdown example wanted
| > | thread-index: AcYhCvvu8ioH0gHQQneCkODBfJlbKQ==
| > | X-WBNR-Posting-Host: 24.73.223.27
| > | From: "=?Utf-8?B?VGRhclRkYXI=?=" <Tdar@noemail.nospam>
| > | References:  <DB561767-E612-4C0E-A000-91321BDF2***@microsoft.com>
| > <d0xSqF$HGHA.3***@TK2MSFTNGXA02.phx.gbl>
| > <77EA8A99-ADF2-41D9-BEC3-75547BDB0***@microsoft.com>
| > <yQoe$hLIGHA.3***@TK2MSFTNGXA02.phx.gbl>
| > | Subject: RE: Itemtemplace and many to one dropdown example wanted
| > | Date: Tue, 24 Jan 2006 09:24:08 -0800
| > | Lines: 415
| > | Message-ID: <FDD8CF80-536E-42A7-B520-B2924B376***@microsoft.com>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > |     charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.webcontrols:32773
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| > |
| > | Not sure how to answer your question but in the detailsview they will
| > should
| > | always be in the same postition of course that depends on what you
are
| > going
| > | to tell me is the best way to go about this in asp.net 2.
| > |
| > | here is the code
| > |
| > |
| > | <%@ Page Language="VB" MasterPageFile="~/Site.master"
| > | AutoEventWireup="false" CodeFile="ShowShipDetails.aspx.vb"
| > | Inherits="Shipping_PreparePackage_ShowShipDetails" title="Untitled
Page"
| > %>
| > | <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
| > | Runat="Server">
| > |      <asp:DetailsView ID="DetailsView1" runat="server"
| > | AutoGenerateRows="False"
| > |         DataKeyNames="ShipKey" DataSourceID="ObjectDataSource1"
| > | Height="50px" Width="275px">
| > |         <Fields>
| > |             <asp:BoundField DataField="ShipKey" HeaderText="ShipKey"
| > | SortExpression="ShipKey" />
| > |             <asp:BoundField DataField="DBMANTransNumber"
| > | HeaderText="Transaction Number" SortExpression="DBMANTransNumber" />
| > |             <asp:TemplateField HeaderText="User Name"
| > SortExpression="UserId">
| > |                 <EditItemTemplate>
| > |                     <asp:DropDownList ID="DropDownList2"
runat="server"
| > | DataSourceID="SqlDataSource2"
| > |                         DataTextField="UserName"
DataValueField="UserId"
| > | Enabled="False" SelectedValue='<%# Bind("UserId") %>'>
| > |                     </asp:DropDownList>
| > |                 </EditItemTemplate>
| > |                 <InsertItemTemplate>
| > |                     <asp:DropDownList ID="DropDownList9"
runat="server"
| > | DataSourceID="SqlDataSource2"
| > |                         DataTextField="UserName"
DataValueField="UserId"
| > | SelectedValue='<%# Bind("UserId") %>'>
| > |                     </asp:DropDownList>
| > |                 </InsertItemTemplate>
| > |                 <ItemTemplate>
| > |                     <asp:DropDownList ID="DropDownList1"
runat="server"
| > | DataSourceID="SqlDataSource2"
| > |                         DataTextField="UserName"
DataValueField="UserId"
| > | Enabled="False" SelectedValue='<%# Bind("UserId") %>'>
| > |                     </asp:DropDownList>
| > |                 </ItemTemplate>
| > |             </asp:TemplateField>
| > |             <asp:CheckBoxField DataField="SignatureReq"
| > | HeaderText="Signature Required?" SortExpression="SignatureReq" />
| > |             <asp:BoundField DataField="ShiptoCompany"
| > HeaderText="Company"
| > | SortExpression="ShiptoCompany" />
| > |             <asp:BoundField DataField="ShiptoName" HeaderText="Name"
| > | SortExpression="ShiptoName" />
| > |             <asp:BoundField DataField="ShipToAddress"
| > HeaderText="Address"
| > | SortExpression="ShipToAddress" />
| > |             <asp:BoundField DataField="ShipToAddress2"
| > HeaderText="Address2"
| > | SortExpression="ShipToAddress2" />
| > |             <asp:TemplateField HeaderText="City"
| > SortExpression="ShipCity">
| > |                 <EditItemTemplate>
| > |                     <asp:DropDownList ID="DropDownList4"
runat="server"
| > | DataSourceID="SqlDataSource1"
| > |                         DataTextField="CITY" DataValueField="CityKey"
| > | SelectedValue='<%# Bind("ShipCity") %>'>
| > |                     </asp:DropDownList>
| > |                 </EditItemTemplate>
| > |                 <InsertItemTemplate>
| > |                     <asp:TextBox ID="TextBox2" runat="server"
Text='<%#
| > | Bind("ShipCity") %>'></asp:TextBox>
| > |                 </InsertItemTemplate>
| > |                 <ItemTemplate>
| > |                     <asp:DropDownList ID="DropDownList3"
runat="server"
| > | DataSourceID="SqlDataSource1"
| > |                         DataTextField="CITY" DataValueField="CityKey"
| > | Enabled="False" SelectedValue='<%# Bind("ShipCity") %>'>
| > |                     </asp:DropDownList>
| > |                 </ItemTemplate>
| > |             </asp:TemplateField>
| > |             <asp:TemplateField HeaderText="State"
| > SortExpression="ShipState">
| > |                 <EditItemTemplate>
| > |                     <asp:DropDownList ID="DropDownList6"
runat="server"
| > | DataSourceID="SqlDataSource3"
| > |                         DataTextField="StateName"
| > DataValueField="StateKey"
| > | Enabled="False" SelectedValue='<%# Bind("ShipState") %>'>
| > |                     </asp:DropDownList>
| > |                 </EditItemTemplate>
| > |                 <InsertItemTemplate>
| > |                     <asp:TextBox ID="TextBox4" runat="server"
Text='<%#
| > | Bind("ShipState") %>'></asp:TextBox>
| > |                 </InsertItemTemplate>
| > |                 <ItemTemplate>
| > |                     <asp:DropDownList ID="DropDownList5"
runat="server"
| > | DataSourceID="SqlDataSource3"
| > |                         DataTextField="StateName"
| > DataValueField="StateKey"
| > | Enabled="False" SelectedValue='<%# Bind("ShipState") %>'>
| > |                     </asp:DropDownList>
| > |                 </ItemTemplate>
| > |             </asp:TemplateField>
| > |             <asp:BoundField DataField="ZipCode" HeaderText="Zip Code"
| > | SortExpression="ZipCode" />
| > |             <asp:TemplateField HeaderText="Country"
| > | SortExpression="ShipCountry">
| > |                 <EditItemTemplate>
| > |                     <asp:DropDownList ID="DropDownList8"
runat="server"
| > | DataSourceID="SqlDataSource4"
| > |                         DataTextField="Country"
| > DataValueField="CountryKey"
| > | Enabled="False" SelectedValue='<%# Bind("ShipCountry") %>'>
| > |                     </asp:DropDownList>
| > |                 </EditItemTemplate>
| > |                 <InsertItemTemplate>
| > |                     <asp:TextBox ID="TextBox3" runat="server"
Text='<%#
| > | Bind("ShipCountry") %>'></asp:TextBox>
| > |                 </InsertItemTemplate>
| > |                 <ItemTemplate>
| > |                     <asp:DropDownList ID="DropDownList7"
runat="server"
| > | DataSourceID="SqlDataSource4"
| > |                         DataTextField="Country"
| > DataValueField="CountryKey"
| > | Enabled="False" SelectedValue='<%# Bind("ShipCountry") %>'>
| > |                     </asp:DropDownList>
| > |                 </ItemTemplate>
| > |             </asp:TemplateField>
| > |             <asp:CommandField ShowEditButton="True" />
| > |         </Fields>
| > |     </asp:DetailsView>
| > |     <br />
| > |     <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
| > | DataObjectTypeName=""
| > |         DeleteMethod="Delete"
| > OldValuesParameterFormatString="original_{0}"
| > | SelectMethod="GetData"
| > |         TypeName="ShippingTableAdapters.OrderShipRecordTableAdapter"
| > | UpdateMethod="Update">
| > |         <UpdateParameters>
| > |             <asp:Parameter Name="ShipKey" Type="Object" />
| > |             <asp:Parameter Name="DBMANTransNumber" Type="String" />
| > |             <asp:Parameter Name="UserId" Type="Object" />
| > |             <asp:Parameter Name="SignatureReq" Type="Boolean" />
| > |             <asp:Parameter Name="ShiptoCompany" Type="String" />
| > |             <asp:Parameter Name="ShiptoName" Type="String" />
| > |             <asp:Parameter Name="ShipToAddress" Type="String" />
| > |             <asp:Parameter Name="ShipToAddress2" Type="String" />
| > |             <asp:Parameter Name="ShipCity" Type="Int32" />
| > |             <asp:Parameter Name="ShipCountry" Type="Int32" />
| > |             <asp:Parameter Name="ShipState" Type="Int32" />
| > |             <asp:Parameter Name="ZipCode" Type="String" />
| > |             <asp:Parameter Name="Original_ShipKey" Type="Object" />
| > |         </UpdateParameters>
| > |         <SelectParameters>
| > |             <asp:QueryStringParameter DefaultValue="-1"
Name="ShipKey"
| > | QueryStringField="ShipKey"
| > |                 Type="Object" />
| > |         </SelectParameters>
| > |     </asp:ObjectDataSource>
| > |     <asp:SqlDataSource ID="SqlDataSource1" runat="server"
| > | ConnectionString="<%$
| > | ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
| > |         SelectCommand="SELECT [CityKey], [CITY], [StateKey] FROM
[CITY]
| > | Order by [City]" ></asp:SqlDataSource>
| > |     <asp:SqlDataSource ID="SqlDataSource3" runat="server"
| > | ConnectionString="<%$
| > | ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
| > |         SelectCommand="SELECT [StateKey], [StateName], [StateCode]
FROM
| > | [State] Order by [StateName]"></asp:SqlDataSource>
| > |     <asp:SqlDataSource ID="SqlDataSource2" runat="server"
| > | ConnectionString="<%$
| > | ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
| > |         SelectCommand="SELECT [UserId], [UserName] FROM
[vw_aspnet_Users]
| > | Order by [UserName]"></asp:SqlDataSource>
| > |     <asp:SqlDataSource ID="SqlDataSource4" runat="server"
| > | ConnectionString="<%$
| > | ConnectionStrings:SilverQueen_Main_SystemConnectionString1 %>"
| > |         SelectCommand="SELECT [CountryKey], [Country], [CountryCode]
FROM
| > | [Country] Order by [Country]"></asp:SqlDataSource>
| > | </asp:Content>
| > |
| > |
| > |
| > | "Steven Cheng[MSFT]" wrote:
| > |
| > | > Thanks for your response Tdar,
| > | >
| > | > So your actual scenario is a bit more complex than I've expected. 
As
| > you
| > | > mentioned:
| > | >
| > | > ====================
| > | >  but how to a change one dropdown contents based on anothers
current
| > | > selection.
| > | > =======================
| > | >
| > | > do you mean that there is another dropdownlist control(state info)
| > which is
| > | > used as filter of the City dropdownlist? If so, I think how to bind
the
| > | > dropdownlists depend on their relationship in the control
collection.
| > Are
| > | > they put in the same parent control (a certain column in
| > | > GridView/DetailsView or ....)? 
| > | >
| > | > Please feel free to let me know if there's anything I misunderstood.
| > | >
| > | > 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.)
| > | >
| > | > --------------------
| > | > | Thread-Topic: Itemtemplace and many to one dropdown example wanted
| > | > | thread-index: AcYgRZOzuS1EF2bwSpGIUCSqYZPYaQ==
| > | > | X-WBNR-Posting-Host: 24.73.223.27
| > | > | From: "=?Utf-8?B?VGRhclRkYXI=?=" <Tdar@noemail.nospam>
| > | > | References:  <DB561767-E612-4C0E-A000-91321BDF2***@microsoft.com>
| > | > <d0xSqF$HGHA.3***@TK2MSFTNGXA02.phx.gbl>
| > | > | Subject: RE: Itemtemplace and many to one dropdown example wanted
| > | > | Date: Mon, 23 Jan 2006 09:51:02 -0800
| > | > | Lines: 172
| > | > | Message-ID: <77EA8A99-ADF2-41D9-BEC3-75547BDB0***@microsoft.com>
| > | > | MIME-Version: 1.0
| > | > | Content-Type: text/plain;
| > | > |     charset="Utf-8"
| > | > | Content-Transfer-Encoding: 7bit
| > | > | X-Newsreader: Microsoft CDO for Windows 2000
| > | > | Content-Class: urn:content-classes:message
| > | > | Importance: normal
| > | > | Priority: normal
| > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | > | Xref: TK2MSFTNGXA02.phx.gbl
| > | > microsoft.public.dotnet.framework.aspnet.webcontrols:32750
| > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | > |
|