简体   繁体   English

“不包含…的定义,也没有扩展方法…接受类型错误的第一个参数

[英]“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.

相关问题 可以找到错误 CS1061“……不包含定义且没有扩展方法……接受类型的第一个参数” - Error CS1061 “…Does Not Contain Definition and No Extension Method…accepting a first argument of type ” could be found 扩展方法。 不包含的定义,也没有扩展方法接受类型的第一个参数 - Extension Method. Does not contain a definition for and no extension method accepting a first argument of type “Type”不包含“Assembly”的定义,并且找不到接受“Type”类型的第一个参数的扩展方法“Assembly” - 'Type' does not contain a definition for 'Assembly' and no extension method 'Assembly' accepting first argument of type 'Type' could be found 继承:不包含定义,也没有接受第一个参数的扩展方法 - Inheritance : does not contain a definition for and no extension method accepting a first argument 不包含定义,也不包含接受第一个参数的扩展方法 - does not contain a definition for and no extension method accepting a first argument 错误 CS1061:“DbSet<t> '不包含'FromSql'的定义并且没有扩展方法'FromSql'接受类型为'DbSet的第一个参数<t> '</t></t> - Error CS1061: 'DbSet<T>' does not contain a definition for 'FromSql' and no extension method 'FromSql' accepting a first argument of type 'DbSet<T>' List 不包含“ConvertAll”的定义,也没有接受“List&lt; &gt;”类型的第一个参数的扩展方法“ConvertAll” - List does not contain a definition for 'ConvertAll' and no extension method 'ConvertAll' accepting a first argument of type 'List< >' &#39;object&#39;不包含&#39;NewRow&#39;的定义,并且找不到找到接受&#39;object&#39;类型的第一个参数的扩展方法&#39;NewRow&#39; - 'object' does not contain a definition for 'NewRow' and no extension method 'NewRow' accepting a first argument of type 'object' could be found &#39;&#39;不包含&#39;Session&#39;的定义并且没有扩展方法&#39;可以找到接受&#39;object&#39;类型的第一个参数 - ''does not contain a definition for 'Session' and no extension method '' accepting a first argument of type 'object' could be found “对象”不包含“添加”的定义,并且找不到接受“对象”类型的第一个参数的扩展方法“添加” - 'object' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'object' could be found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM