Dropdownlist does not work within Detailsview

Asked

Viewed 186 times

0

I have a DetailsView with several fields and a DropDownList that should update the field sexoAnimal with Male (M) or Female (F).

I added a ControlParameter in the SqlDataSource, the parameter takes the value selected in DropDown.

If I leave the DropDownList within the DetailsView, he makes that mistake:

Unable to find'sexDrop 'control in Controlparameter'sexoC'.

If I pull him out of the DetailsView (example: below), it updates the field Sexo normally.

What can/should I do to work inside the DetailsView?

Cód Dropdown:

<asp:DropDownList ID="sexoDrop" runat="server">
    <asp:ListItem Value="M">Macho</asp:ListItem>
    <asp:ListItem Value="F">Fêmea</asp:ListItem>
</asp:DropDownList>

Parameter:

<asp:ControlParameter Name="sexoC" ControlID="sexoDrop" PropertyName="SelectedValue" />
  • You could post a larger chunk of code from your APSX and tbm from your source ASPX.Cs q calls the methods?

  • @tchicotti, everything is being done in . aspx, using the Detailsview components with Sqldatasource.

1 answer

1

As I answered your other question: How to use the Dropdownlist Selectedvalue value? One way to do this is by getting the Dropdownlist from Detailsview and doing the update logic inside the code-Behind. I never used Sqldatasource, but for the error that is giving the problem is that Dropdownlist is not accessible to Sqldatasource. In the same way that in code-Behind it is necessary to perform a dvid.Findcontrol("sexDrop"), it will be necessary to perform the same in Sqldatasource. Now how to do this I do not know, because I have never used this control.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.