Thanks for replying.
This is bad news for me, because i defined an InsertItemTemplate containing
a dropdownlist with the possible values into the detailsview (put into
insert mode) .
Result: the Controlparameter can't find controlID="dropdownlist1".
How can i put the selectedvalue of the dropdownlist into that template field
for inserting the new record?
Thanks again
Ben
See part of code:
<asp:SqlDataSource ID="SqlDataSource1"
...
InsertCommand="INSERT INTO [pc] ([name], [place]) VALUES (?, ?, @pl)"
"OldValuesParameterFormatString="original_{0}"
ProviderName="System.Data.OleDb">
<InsertParameters>
<asp

arameter Name="name" Type="String" />
<asp:ControlParameter ControlID="dropdownlist1" Name="pl"
PropertyName="SelectedValue" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp

etailsView ID="DetailsView1" runat="server" DataKeyNames="pcnr"
DataSourceID="SqlDataSource1" DefaultMode="Insert">
<Fields>
<asp:BoundField DataField="pcnr" HeaderText="pcnr"
ReadOnly="True"
<asp:BoundField DataField="name" />
<asp:TemplateField >
<InsertItemTemplate>
<asp

ropDownList ID="DropDownList1"
runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2"
DataTextField="place DataValueField="placel">
</asp

ropDownList>
</InsertItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp

etailsView>
asp:SqlDataSource ID="SqlDataSource2"
....
"Marina Levit [MVP]" <> schreef in bericht
news:%...
> Because it is just a template. If there are 20 rows, there will be 20
> labels. If there are 50 rows, there will be 50 labels.
> So which one could 'myLabel' possibly refer to? How would the page know
> which one of the unknown number of labels that will be created youw ant?
>
> It can't.
>
> "Ben" <> wrote in message
> news:...
>> Hi,
>>
>> In the code-behind, i can refer to the dropdownlist defined in the aspx
>> file with this (e.g.)
>> dropdownlist1.sekectedvalue = ...
>>
>> but why can i not refer to the label defined in the TemplateField in the
>> same aspx file like below?
>> This gives the error: "can't find control 'mylabel' ":
>> mylabel.text="ok"
>>
>> <asp:TemplateField>
>> <ItemTemplate>
>> <asp:Label ID="mylabel" Runat="server"
>> Text='<%# Bind("field1") %>'></asp:Label>
>> </ItemTemplate>
>> </asp:TemplateField>
>>
>> <asp
ropDownList ID="dropdownlist1" runat="server" AutoPostBack="True" >
>> </asp
ropDownList>
>>
>> Thanks
>> Ben
>>
>
>