Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdownlist in a detailsview updating

Status
Not open for further replies.

NickMalloy

Programmer
Apr 15, 2005
68
US
I have the following code that has a dropdownlist in the detailsview. When I click update I get this

Could not find control 'drpTime' in ControlParameter 'startTimeDisplay'.

<code>
<asp:DetailsView ID="Detail1" runat="server" DataSourceID="ObjectDataSource3" Width="350px"
AutoGenerateRows="False" HeaderText="Press Release" DataKeyNames="ID">
<Fields>
<asp:BoundField ReadOnly="True" InsertVisible="False" HeaderText="ID" DataField="ID" />
<asp:BoundField HeaderText="title" DataField="title" />
<asp:BoundField HeaderText="Press URL" DataField="url" />
<asp:TemplateField>
<HeaderTemplate>
Keywords
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="keywordDisplay" runat="server" Text='<%#Bind("keywords") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtkeywords" runat="server" Text='<%#Bind("keywords") %>' TextMode="multiLine"
Rows="5" Columns="35"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Start Date" DataField="startDate" />
<asp:TemplateField>
<HeaderTemplate>
Start Time
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="StartTimeDisplay" runat="server" Text='<%#Bind("startTime") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
Current Start Time:&nbsp;&nbsp;
<asp:Label ID="tmpStartTime" runat="server" Text='<%#Bind("startTime") %>'></asp:Label>
<asp:DropDownList ID="drpTime" runat="server" SelectedValue='<%#Bind("startTimeDisplay") %>'>
<asp:ListItem Text="1" Value="1:00"></asp:ListItem>
<asp:ListItem Text="2" Value="2:00"></asp:ListItem>
<asp:ListItem Text="3" Value="3:00"></asp:ListItem>
<asp:ListItem Text="4" Value="4:00"></asp:ListItem>
<asp:ListItem Text="5" Value="5:00"></asp:ListItem>
<asp:ListItem Text="6" Value="6:00"></asp:ListItem>
<asp:ListItem Text="7" Value="7:00"></asp:ListItem>
<asp:ListItem Text="8" Value="8:00"></asp:ListItem>
<asp:ListItem Text="9" Value="9:00"></asp:ListItem>
<asp:ListItem Text="10" Value="10:00"></asp:ListItem>
<asp:ListItem Text="11" Value="11:00"></asp:ListItem>
<asp:ListItem Text="12" Value="12:00"></asp:ListItem>
</asp:DropDownList>
&nbsp;<asp:DropDownList ID="drpTimeFrame" runat="server" SelectedValue='<%#Bind("AMPM") %>'>
<asp:ListItem Text="AM" Value="AM"></asp:ListItem>
<asp:ListItem Text="PM" Value="PM"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="End Date" DataField="endDate" />
<asp:CheckBoxField DataField="archived" HeaderText="Not Visible" SortExpression="archived" />
<asp:CommandField ShowEditButton="True" />
</Fields>
</asp:DetailsView>
<asp:ObjectDataSource ID="ObjectDataSource3" runat="server" SelectMethod="getDV"
UpdateMethod="SaveDataView" FilterExpression="ID='{0}'" TypeName="clsPressRoom">
<SelectParameters>
<asp:parameter Name="Columns" Type="String" DefaultValue="ID,title,url,keywords,convert(varchar,startDate,101) as startdate, LTRIM(SUBSTRING(CONVERT(varChar, startDate, 100), 12, 8)) AS startTime , convert(varchar,endDate,101) as endDate,archived,entity, CASE WHEN DATEPART(Hh, startDate) < 12 THEN 'AM' ELSE 'PM' END AS AMPM, LTRIM(SUBSTRING(CONVERT(varChar, startDate, 100), 12, 6)) AS startTimeDisplay" />
<asp:parameter Name="Where" Type="String" DefaultValue="GETDATE() BETWEEN startDate AND endDate" />
<asp:parameter Name="OrderBy" Type="String" DefaultValue="ID" />
<asp:parameter Name="Direction" Type="String" DefaultValue="DESC" />
<asp:ControlParameter Name="Search" ControlID="txtsearch" />
</SelectParameters>
<FilterParameters>
<asp:ControlParameter Name="singleID" ControlID="GridView1" PropertyName="SelectedValue" />
</FilterParameters>
<UpdateParameters>
<asp:parameter Name="ID" Type="string" />
<asp:parameter Name="title" Type="string" />
<asp:parameter Name="url" Type="string" />
<asp:FormParameter FormField="txtkeywords" Type="string" Name="keywords" />
<asp:parameter Name="startDate" Type="dateTime" />
<asp:ControlParameter ControlID="drpTime" Type="dateTime" Name="startTimeDisplay"
PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="drpTimeFrame" Type="string" Name="AMPM" PropertyName="SelectedValue" />
<asp:parameter Name="endDate" Type="dateTime" />
<asp:parameter Name="archived" Type="Boolean" />
</UpdateParameters>
</asp:ObjectDataSource>
</code>
 
I think you are missing some things in your DDL,
Code:
<asp:DropDownList
          id="drpTime"
          runat="server"
          DataTextField="Time"
          DataValueField="TimeID"
          [b]DataSourceID="ObjectDataSource3"[/b]>
      </asp:DropDownList>

and to post code its the [ not the < !

let us know
 
There is no datasource for the DDL because it doesn't populate from a database. It is all on the page.
 
Yeah, but i think you have to associate with the datasource to apply the update parameters. Have u tried, does it get error, simplify it a bit?
Code:
<asp:DropDownList ID="drpTime" runat="server" SelectedValue='<%#Bind("startTimeDisplay") %>'
[b]DataSourceID="ObjectDataSource3"[/b]>
                                    <asp:ListItem Text="1" Value="1:00"></asp:ListItem>
                                    <asp:ListItem Text="2" Value="2:00"></asp:ListItem>
                                    <asp:ListItem Text="3" Value="3:00"></asp:ListItem>
                                    <asp:ListItem Text="4" Value="4:00"></asp:ListItem>
                                    <asp:ListItem Text="5" Value="5:00"></asp:ListItem>
                                    <asp:ListItem Text="6" Value="6:00"></asp:ListItem>
                                    <asp:ListItem Text="7" Value="7:00"></asp:ListItem>
                                    <asp:ListItem Text="8" Value="8:00"></asp:ListItem>
                                    <asp:ListItem Text="9" Value="9:00"></asp:ListItem>
                                    <asp:ListItem Text="10" Value="10:00"></asp:ListItem>
                                    <asp:ListItem Text="11" Value="11:00"></asp:ListItem>
                                    <asp:ListItem Text="12" Value="12:00"></asp:ListItem>
                                </asp:DropDownList>

as in this example...
Code:
<asp:DropDownList ID="ddlPriority" runat="server"
SelectedValue='<%# Bind("priority") %>' DataSourceID="sqlDS">
<asp:ListItem Value="0">low</asp:ListItem>
<asp:ListItem Value="1">middle</asp:ListItem>
<asp:ListItem Value="2">high</asp:ListItem>
</asp:DropDownList>
 
I get this error

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

When I remove tthe selectedValue tag. The dropdown contains nothing related to my data. when I put the datavalue column, the only thing in the dropdown is the current time. and I still get the error on update.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top