I’ve got the following error:
'DirectActivity' does not contain a definition for 'ddl_jobcode_Id2' and no extension method 'ddl_jobcode_Id2' accepting a first argument of type 'DirectActivity' could be found (are you missing a using directive or an assembly reference?)
In my aspx, I created a DropDownList like this:
<asp:DropDownList ID="ddl_jobcode_Id2" runat="server" DataSourceID="ddl_ActivityType2"
DataTextField="jobCode" DataValueField="ID" SelectedValue='<%# Bind("jobCode_ID2", "{0}") %>'
OnDataBound="ddl_jobcode_Id2_DataBound"
onselectedindexchanged="ddl_jobcode_Id2_SelectedIndexChanged1"
AutoPostBack="True">
</asp:DropDownList>
I need to add a control so that in the .cs file I worte
protected void ddl_jobcode_Id2_SelectedIndexChanged1(object sender, EventArgs e)
{
if(this.ddl_jobcode_Id2.SelectedValue == "19" )
{ ...}}
and it just shows this error on ddl_jobcode_Id2
could anyone help me please? many thanks!!!
I notice you’re binding a value to your
SelectedValueproperty. This probably means you have thisDropDownListin someTemplateof a data control.In that case you’ll need to set a handler for an event of your data control where your template has been instatiated (I can’t tell without knowing the exact control), and
FindControl("ddl_jobcode_Id2") your way to yourDropDownListin code-behind.