[英]“does not contain a definition for …and no extension method …accepting a first argument for type error
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: 在我的aspx中,我创建了一个DropDownList,如下所示:
<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 我需要添加一个控件,以便在.cs文件中输入
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
它只是在ddl_jobcode_Id2
上显示此错误
could anyone help me please? 有人可以帮我吗? many thanks!!! 非常感谢!!!
I notice you're binding a value to your SelectedValue
property. 我注意到您正在将一个值绑定到SelectedValue
属性。 This probably means you have this DropDownList
in some Template
of a data control. 这可能意味着您在数据控件的某些Template
中具有此DropDownList
。 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 your DropDownList
in code-behind. 在这种情况下,您需要为数据控件的事件设置一个处理程序,该事件中模板已被实例化(我不知道确切的控件无法知道),而FindControl
( "ddl_jobcode_Id2"
) "ddl_jobcode_Id2"
您的DropDownList
了一种方法代码隐藏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.