car123 0 Newbie Poster

Hello all;

I have a couple of DropDownList fields and a submit button. When the button is clicked, I'd like the 'ddlPartNumber.SelectedValue' to populate a field on a DetailsView. The DetailsView1 is in Insert mode and the field I would like to populate is 'PartNumber' which is a Text field. I'm including snippets of the code. I know this will be accomplished in code behind, but am at a loss as to just where to put that code.

You're help is greatly appreciated.

Snippets of aspx page:

<%@ Page Language="VB" MasterPageFile="~/MasterPages/MasterHome.master" AutoEventWireup="false" CodeFile="TestNew.aspx.vb" Inherits="Samples_TestNew" title="Untitled Page" %>

 <asp:Label ID="lblNomenclature" runat="server" Text="Find a Nomenclature Here" 
                    Font-Bold="True" Font-Names="Comic Sans MS" Font-Size="10pt" ForeColor="Black"></asp:Label>
                <br />
                <asp:DropDownList ID="ddlPartName" runat="server" DataSourceID="SqlPartName" 
                    DataTextField="PartName" DataValueField="PartName" AppendDataBoundItems="True" 
                    AutoPostBack="True">
                    <asp:ListItem>----------</asp:ListItem>
                </asp:DropDownList>
                <cc1:ListSearchExtender ID="ddlPartName_ListSearchExtender" runat="server" 
                    Enabled="True" TargetControlID="ddlPartName">
                </cc1:ListSearchExtender>
                <asp:SqlDataSource ID="SqlPartName" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:NDIConnectionString %>" 
                    
                        SelectCommand="SELECT DISTINCT [PartName] FROM [tblPartNumbers] ORDER BY [PartName]">
                </asp:SqlDataSource>
                
                <br />
                <asp:Label ID="lblPartNumber" runat="server" Font-Bold="True" 
                    Font-Names="Comic Sans MS" Font-Size="10pt" ForeColor="Black">
                    Available Part Numbers Are:
                </asp:Label>
                <br />
                    <asp:DropDownList ID="ddlPartNumber" runat="server" AutoPostBack="False" 
                        DataSourceID="SqlPartNumber" DataTextField="PartNumber" 
                        DataValueField="PartNumber" AppendDataBoundItems="True">
                        <asp:ListItem>---------</asp:ListItem>
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="SqlPartNumber" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:NDIConnectionString %>" 
                        SelectCommand="SELECT DISTINCT [PartNumber] FROM [tblPartNumbers] WHERE ([PartName] = @PartName2) ORDER BY [PartNumber]">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="ddlPartName" Name="PartName2" 
                                PropertyName="SelectedValue" Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                    <br /><br />  
                    <asp:Button ID="btnSubmit" runat="server" Text="Submit" BackColor="Plum" 
                        ForeColor="black" />
                    <br />
  <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
                    BackColor="#FFFFCC" BorderStyle="Double" BorderWidth="10px" CellPadding="2" 
                    CellSpacing="2" DataKeyNames="id" DataSourceID="SqlDataSource1" Height="50px" 
                    Width="622px" DefaultMode="Insert" style="margin-left: 0px">
                    <Fields>
                        <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" 
                            ReadOnly="True" SortExpression="id" />
                        <asp:TemplateField HeaderText="Date of Inspection" SortExpression="Date">
                            <InsertItemTemplate>
                                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Date") %>' TabIndex="0">
                                </asp:TextBox>
                                <rjs:PopCalendar ID="PopCalendar2" runat="server" Control="TextBox1" 
                                    ToolTip="Click to select a date" Format="mm dd yyyy" Separator="/" />
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("Date") %>'></asp:Label>
                            </ItemTemplate>
                            <ControlStyle BorderStyle="Solid" />
                            <HeaderStyle BorderStyle="None" Font-Bold="True" HorizontalAlign="Right" />
                            <ItemStyle BorderStyle="None" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Work Order" SortExpression="Won">
                            <ItemTemplate>
                                <asp:Label ID="Label11" runat="server" Text='<%# Bind("Won") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Won") %>'></asp:TextBox>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Won") %>' TabIndex="1">
                                </asp:TextBox>
                            </InsertItemTemplate>
                            <ControlStyle BorderStyle="Solid" />
                            <HeaderStyle BorderStyle="None" Font-Bold="True" HorizontalAlign="Right" />
                            <ItemStyle BorderStyle="None" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Nomenclature" SortExpression="Nomenclature">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Nomenclature") %>'></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label8" runat="server" Text='<%# Bind("Nomenclature") %>'></asp:Label>
                            </ItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox ID="txtNom" runat="server" Text='<%# Bind("Nomenclature") %>'  TabIndex="4">
                                </asp:TextBox>
                            </InsertItemTemplate>
                            <ControlStyle BorderStyle="Solid" Width="300px" />
                            <HeaderStyle BorderStyle="None" Font-Bold="True" HorizontalAlign="Right" />
                            <ItemStyle BorderStyle="None" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Part Number" SortExpression="PartNumber">
                            <InsertItemTemplate>
                                <asp:TextBox ID="txtPartNumber" runat="server" Text='<%# Bind("PartNumber") %>'  
                                    TabIndex="5">
                                </asp:TextBox>
                            </InsertItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("PartNumber") %>'></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label9" runat="server" Text='<%# Bind("PartNumber") %>'></asp:Label>
                            </ItemTemplate>
                            <ControlStyle BorderStyle="Solid" Width="160px" />
                            <HeaderStyle BorderStyle="None" Font-Bold="True" HorizontalAlign="Right" />
                            <ItemStyle BorderStyle="None" />
                        </asp:TemplateField>

Code in VB would be really nice. Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.