在ControlParameter找不到控制里面的EditItemTemplate [英] Could not find Control in ControlParameter inside EditItemTemplate

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

问题描述

我的工作动态数据网站上,我遇到了一堵墙。我有一个详细信息页面,每个员工的详细信息可以看到,然后我有一个单独的页面编辑每个员工。我这样做是因为我需要使用部门DropDownList的箱子和工作在各个部门。不过,我无法访问部门DDL和我想这是因为它是一个EditItemTemplate中内。以下是我有:

I am working on a Dynamic Data website and I have run into a wall. I have a Details page where the details for each employee can be seen, and then I have a separate page to edit each employee. I did this because I need to use DropDownList boxes for Department and Job in each department. Nevertheless, I am having trouble accessing the department ddl and I think it is because it is inside an EditItemTemplate. Here is what I have:

<asp:DetailsView ID="dvEmployee" 
                    DataSourceID="EmpDVds" 
                    AutoGenerateRows="false" 
                    DataKeyNames="Id" 
                    GridLines="None" 
                    CellSpacing="10" 
                    runat="server" DefaultMode="Edit">
                    <Fields>
                        <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Department: ">
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddlDept" DataSourceID="DeptDDLds" DataTextField = "DepartmentName" DataValueField = "Id" runat="server" SelectedValue='<%#Bind("DeptID") %>' />
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Job Code: ">
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddlJob" DataSourceID="JobDDLds" DataTextField = "JobName" DataValueField = "Id" runat="server" />
                            </EditItemTemplate>
                        </asp:TemplateField>
                    </Fields>

然后我试图使用ddlDept的SelectedValue来填充ddlJob。这是我想使用的数据源。

Then I am trying to use the ddlDept SelectedValue to populate the ddlJob. Here is the DataSource I am trying to use.

<asp:SqlDataSource ID="JobDDLds"
                    SelectCommand="
                        SELECT 
                        Id, 
                        Code+' - '+[Desc] AS JobName,
                        Department_Id 
                        FROM 
                        JobCodes 
                        WHERE
                        JobCodes.Department_Id = @DeptID"
                    ConnectionString="<%$ConnectionStrings:TrainingDatabaseConnection %>" runat="server" >
                        <SelectParameters>
                            <asp:ControlParameter ControlID="ddlDept" PropertyName="SelectedValue"
                                    Name="DeptID" Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>

我知道,选择参数的格式是正确的,因为我使用另一个DDL来填充在DetailsView,我知道CS是正确的,因为我在和AddEmployee页面中使用它成功的部门和工作$ C $之间的关系。

I know that the format of the Select parameter is correct because I am using another ddl to populate the DetailsView and I know the relationship between Departments and JobCodes is correct because I am using it successfully in and AddEmployee page.

以下是错误我得到:

在ControlParameterDEPTID找不到控制'ddlDept。

Could not find control 'ddlDept' in ControlParameter 'DeptID'.

我我在假定它不能访问ddlDept由它的ID,因为它是在EditItemTemplate中正确?我该如何解决这个问题?如何实现这个其他的建议?任何及所有帮助是极大的AP preciated。

I am I correct in assuming that it cannot access the ddlDept by it's ID because it is in the EditItemTemplate? How can I fix this? Other suggestions on how to achieve this? Any and all help is greatly appreciated.

推荐答案

我发现这个链接有助于解决无服务器端:的Solving错误,在ControlParameterXXX找不到控制'XXX'。

I found this link helps to solve without server side: Solving the error "Could not find control 'xxx' in ControlParameter 'xxx'."

笔者说你可以使用美元CHAR( $ )访问内部控制。

the author says that you can use the dollar char ($) to access the inner control.

例如:

控件ID =$ dvEmployee ddlDept

将得到ddlDept的值是dvEmployee的内部控制

will get the value of ddlDept that is a inner control of dvEmployee

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

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