未找到控制参数 [英] controlparameter not found

查看:281
本文介绍了未找到控制参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < asp:ControlParameter ControlID =错误:无法在ControlParameter'mycontrolparam'中找到控件'mytextfield' mytextfieldName =mycontrolparamPropertyName =TextType =Int32/> 

错误是因为mytextfield在面板控件中,我需要FindControl方法才能找到它。但是我想找到一个快速的解决方案,如果有任何,如何使mytextfield可见的控制参数。相同的代码在不同的页面上工作,但不在这个页面上。请记住,我想对现有的代码做最小的修改。



这里是我从微软网站上复制过来的类似代码。

  < asp:SqlDataSource id =Employeesrunat =server
ConnectionString =<%$ ConnectionStrings:Northwind%>
SelectCommand =SELECT LastName FROM Employees WHERE Title = @Title>
< SelectParameters>
< asp:ControlParameter Name =Title
ControlID =DropDownList1
PropertyName =SelectedValue/>
< / SelectParameters>
< / asp:sqldatasource>

想要提一下:'mytextfield'是只读文本框。它在另一个页面上工作正常。

解决方案

我自己:如果一个控件嵌入到面板中,它通过该面板的FindControl方法。它仍然没有为我工作,我不得不放弃它,并使用一种不同的方法。

否则使用以下方法

  FindControl(MyControlID)


Error: Could not find control 'mytextfield' in ControlParameter 'mycontrolparam'.

<asp:ControlParameter ControlID="mytextfield" Name="mycontrolparam" PropertyName="Text" Type="Int32" />

The error is because "mytextfield" is inside a panel control and I would need FindControl method to find it. But I want to find a quick solution if there is any, how to make mytextfield visible to the control parameter. The same code works on a different page but not on this one. Please keep in mind, I want to make minimum changes to the existing code.

Here is similar code I copied over from Microsoft site.

<asp:SqlDataSource id="Employees" runat="server"
  ConnectionString="<%$ ConnectionStrings:Northwind%>"
  SelectCommand="SELECT LastName FROM Employees WHERE Title = @Title">
  <SelectParameters>
    <asp:ControlParameter Name="Title" 
      ControlID="DropDownList1"
      PropertyName="SelectedValue"/>
  </SelectParameters>
</asp:sqldatasource>

Want to mention: 'mytextfield' is a readonly textfield. It does work OK on the other page though.

解决方案

Myself: If a control is embedded inside a panel, you can only find it through FindControl method of that panel. It still actually did not work for me and I had to abandon it and use a a different method.

Use the following method otherwise

FindControl("MyControlID")

这篇关于未找到控制参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆