Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 14th, 2006, 08:44 AM
Registered User
 
Join Date: Jul 2006
Location: Naugatuck, CT, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default DropDownList Problem

I have an issue with one of my dropdown lists. Let me explain the application so you can understand the issue better. I have an ASP.NET 2.0 application written in VB that tracks vacation requests one of the fields it tracks is the manager. The data for the manager is pulled from a table that is populated by a script that pulls data from Active Directory.This way the managers are kept up to date. I setup an edit page that uses a dropdown list so that we can change the manager if a user changes position or the manager leaves. The problem I have is if a manager leaves my edit page errors because the manager ddl no longer has the old manager in the list and the request references the old manager. How do I set it so that when it encounters the error it changes to a default value? To complicate this a little more the DDL is in a templatefield of a details view.

Here is the Details view code:

 <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
            CellPadding="4" DataSourceID="SqlDataSource4" ForeColor="#333333" GridLines="None"
            Height="50px" Width="329px" DataKeyNames="RecNum" HeaderText="Request Details">
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
            <EditRowStyle BackColor="#999999" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <Fields>
                <asp:BoundField DataField="RecNum" HeaderText="RecNum" InsertVisible="False" ReadOnly="True"
                    SortExpression="RecNum" Visible="False" />
                <asp:BoundField DataField="Requester" HeaderText="Requester" SortExpression="Requester" ReadOnly="True" >
                    <ItemStyle Font-Size="Small" />
                    <HeaderStyle Font-Size="Small" />
                </asp:BoundField>
                <asp:TemplateField HeaderText="From" SortExpression="From1">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("From1", "{0:MM/dd/yyyy}") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("From1", "{0:MM/dd/yyyy}") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemStyle Font-Size="Small" />
                    <HeaderStyle Font-Size="Small" />
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("From1", "{0:MM/dd/yyyy}") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="To" SortExpression="To1">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("To1", "{0:MM/dd/yyyy}") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("To1", "{0:MM/dd/yyyy}") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemStyle Font-Size="Small" />
                    <HeaderStyle Font-Size="Small" />
                    <ItemTemplate>
                        <asp:Label ID="Label6" runat="server" Text='<%# Bind("To1", "{0:MM/dd/yyyy}") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="NoDays1" HeaderText="# of Days" SortExpression="NoDays1" >
                    <ItemStyle Font-Size="Small" />
                    <HeaderStyle Font-Size="Small" />
                </asp:BoundField>
                <asp:BoundField DataField="RequestDate" DataFormatString="{0:MM/dd/yyyy}" HeaderText="Request Date"
                    HtmlEncode="False" ReadOnly="True" SortExpression="RequestDate">
                    <ItemStyle Font-Size="Small" />
                    <HeaderStyle Font-Size="Small" />
                </asp:BoundField>
                <asp:TemplateField HeaderText="Request Type" SortExpression="ReqType">
                    <EditItemTemplate>
                        &nbsp;<asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="SqlDataSource8"
                            DataTextField="ReqType" DataValueField="ReqType" SelectedValue='<%# Bind("ReqType") %>'>
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("ReqType") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemStyle Font-Size="Small" />
                    <HeaderStyle Font-Size="Small" />
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("ReqType") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Manager" SortExpression="Manager">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="SqlDataSource7" AppendDataBoundItems="True"
                            DataTextField="Manager_Name" DataValueField="Manager_Name" SelectedValue='<%# Bind("Manager") %>'>
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Manager") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemStyle Font-Size="Small" />
                    <HeaderStyle Font-Size="Small" />
                    <ItemTemplate>
                        <asp:Label ID="Label5" runat="server" Text='<%# Bind("Manager") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Approved" SortExpression="Approved">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="SqlDataSource6"
                            DataTextField="ApprovalStatus" DataValueField="ApprovalStatus" SelectedValue='<%# Bind("Approved") %>'>
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Approved") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemStyle Font-Size="Small" />
                    <HeaderStyle Font-Size="Small" />
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("Approved") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Approver" HeaderText="Approver" SortExpression="Approver" ReadOnly="True" >
                    <ItemStyle Font-Size="Small" />
                    <HeaderStyle Font-Size="Small" />
                </asp:BoundField>
                <asp:BoundField DataField="ApprovedDate" HeaderText="Approved Date" SortExpression="ApprovedDate" ReadOnly="True" >
                    <ItemStyle Font-Size="Small" />
                    <HeaderStyle Font-Size="Small" />
                </asp:BoundField>
                <asp:TemplateField HeaderText="Department" SortExpression="Department">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource5"
                            DataTextField="Department" DataValueField="Department" SelectedValue='<%# Bind("Department") %>'>
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Department") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemStyle Font-Size="Small" />
                    <HeaderStyle Font-Size="Small" />
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Department") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowEditButton="True" ShowDeleteButton="True" >
                    <ItemStyle Font-Size="Small" />
                </asp:CommandField>
            </Fields>
            <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        </asp:DetailsView>

My guess is that I have to do something when the details view is binding to the data but can't figure out exactly what or how to reference the ddl inside the template field.

Any help would be greatly apprecated.




Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in dropdownlist premnaath ASP.NET 2.0 Professional 2 November 29th, 2007 10:01 AM
Dropdownlist Problem monika.vasvani ASP.NET 1.0 and 1.1 Professional 2 November 11th, 2006 09:24 AM
Problem with dropdownlist somnath.kartic ASP.NET 1.0 and 1.1 Basics 3 February 8th, 2006 01:59 AM
dropdownlist problem naresh.net ASP.NET 1.0 and 1.1 Basics 4 July 7th, 2005 01:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.