troubleshooting Question

Template field dropdown errors in detailsview

Avatar of IntercareSupport
IntercareSupport asked on
.NET ProgrammingASP.NET
15 Comments1 Solution1186 ViewsLast Modified:
I am trying to convert a bound field to a  template field.  I want to have a dropdown list where users can use during "Update" mode.  Basically, I'm trying to do what this guy is doing: http://blogs.msdn.com/robburke/archive/2005/04/01/404727.aspx

The error I'm getting is this:

'DropDownList3' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

Any ideas?
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
                                DataSourceID="qry_Enrollment" Height="50px" Width="551px">
                                <Fields>
                                    <asp:BoundField DataField="Enroll_Date" HeaderText="Enroll Date" ReadOnly="True"
                                        SortExpression="Enroll_Date" />
                                    <asp:BoundField DataField="Provider_Assessed" HeaderText="Provider Assessed Date" SortExpression="Provider_Assessed" />
                                    <asp:BoundField DataField="GAIC_Enrollment" HeaderText="GAIC Enrollment" SortExpression="GAIC_Enrollment" />
                                    <asp:BoundField DataField="GA_Other_Enrollment" HeaderText="GA Other Enrollment"
                                        SortExpression="GA_Other_Enrollment" />
                                    <asp:BoundField DataField="Current_Status" HeaderText="Current Status" SortExpression="Current_Status" />
                                    <asp:BoundField DataField="Due_Date" HeaderText="Due Date" ReadOnly="True" SortExpression="Due_Date" />
                                    <asp:BoundField DataField="Pregnancy_Amt" HeaderText="Gravida" SortExpression="Pregnancy_Amt" />
                                    <asp:BoundField DataField="Birth_Amt" HeaderText="Para" SortExpression="Birth_Amt" />
                                    <asp:TemplateField HeaderText="Hospital" SortExpression="Hospital">
                                        <EditItemTemplate>
                                            <asp:DropDownList DataTextField="Hospital" DataValueField="Hospital" ID="DropDownList3" Runat="server" SelectedValue='<%# Bind("Hospital") %>' >
                                                  <asp:ListItem>Lakeland</asp:ListItem>
                                                  <asp:ListItem>Other</asp:ListItem>
                                                  <asp:ListItem>UT</asp:ListItem>
                                                  <asp:ListItem>MD</asp:ListItem>
                                            </asp:DropDownList>
                                        </EditItemTemplate>
                                        <InsertItemTemplate>
                                        </InsertItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("Hospital") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:CheckBoxField DataField="HIPPA" HeaderText="HIPPA" SortExpression="HIPPA" />
                                    <asp:CommandField ShowEditButton="True" />
                                </Fields>
                                <RowStyle BackColor="White" BorderColor="Gainsboro" Font-Size="Smaller" ForeColor="Black" />
                                <FieldHeaderStyle Font-Bold="True" />
                            </asp:DetailsView>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 15 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros