从代码隐藏文件中访问Repeater内部的Control [英] Accessing a Control inside a Repeater from a code behind file

查看:119
本文介绍了从代码隐藏文件中访问Repeater内部的Control的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是asp.net的新手。如果可以,请帮忙。

是否可以引用一个控件(即标签,占位符,文本框)

,它位于代码隐藏文件中的转发器对象中?当我在转发器之外放置控制对象时,我可以从

代码后面的文件中引用它。当我将控制对象放在转发器内时,

我得到需要实例化控制对象的错误。如果我在控件后面的文件中声明控制对象,那么错误就会消失,但我无法引用控件对象组件。请帮忙。

im new to asp.net. please help if u can.
is it possible to refer to a control(ie lable, placeholder, textbox)
that is inside a repeater object from a code behind file? when i place
the control object outside of the repeater, i can refer to it from the
code behind file. when i place the control object inside the repeater,
i get a ''need to instanciate the control object'' error. if i declare
the control object inside the control behind file, the error goes
away, but i cant refer to the control objects components. please help.

推荐答案

Ric,


以下文章解释了它是如何完成的:<

http:/ /msdn.microsoft.com/library/en...formspages.asp

希望这有帮助

Martin

Ric < DJ **************** @ yahoo.com>在留言中写道

news:78 ************************** @ posting.google.c om ...
Hi, Ric,

The following article explains how it is done:

http://msdn.microsoft.com/library/en...formspages.asp

Hope this helps
Martin
"Ric" <dj****************@yahoo.com> wrote in message
news:78**************************@posting.google.c om...
我是asp.net的新手。如果可以,请帮忙。
是否可以从代码隐藏文件中引用转发器对象内的控件(即标签,占位符,文本框)?当我将控制对象放在转发器之外时,我可以从
代码后面的文件中引用它。当我将控制对象放在转发器内时,我得到需要实例化控制对象的错误。如果我在控件后面的文件中声明控件对象,那么错误就会消失,但是我无法引用控件对象组件。请帮帮忙。
im new to asp.net. please help if u can.
is it possible to refer to a control(ie lable, placeholder, textbox)
that is inside a repeater object from a code behind file? when i place
the control object outside of the repeater, i can refer to it from the
code behind file. when i place the control object inside the repeater,
i get a ''need to instanciate the control object'' error. if i declare
the control object inside the control behind file, the error goes
away, but i cant refer to the control objects components. please help.






thx martin。我非常感谢你的帮助。我会给这个网站添加书签。


***通过Developersdex发送 http://www.developersdex.com ***

不要只是参加USENET ......获得奖励!


thx martin. i really appreciate the help. i''ll bookmark this site.

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


thx再次为帮助马丁。我能够使用你的建议

到达转发器内的控制器。另外,我能够理解

更多回合对象,事件和参数。但是,我确定我有更多要学习的东西。


如果你或其他人可以帮我解决另一个问题,请做。


i有一个转发器从数据库中提取作业信息。每个

转发器itemtemplate有一个linkbutton和一行带有标签

(现在)。


< asp: repeater ID =" EmployeeInfo" OnItemCommand =" getActivityList"

runat =" server">


< itemtemplate>

< tr bgcolor =" #CCCCCC">

< td><%#Container.DataItem(0)%>< / td>

< td> <%#Container.DataItem(1)%>< / td>

< td><%#Container.DataItem(2)%>< / td>

< td><%#Container.DataItem(3)%>< / td>

< td><%#Container.DataItem(4) %>< / td>

< td>< asp:linkbutton Text =<%#Container.DataItem(5)%>

runat = " server" />< / td>

< / tr>

< tr>

< td>< ; asp:label id =" litLabel" RUNAT = QUOT;服务器" Text =" labelti"

Visible =" false" />< / td>

< / tr>

< ; / itemtemplate>


当你点击链接按钮时,标签(最终它将是一个

占位符,在另一个转发器中有更多数据库信息)将成为

可以看到工作中的详细信息。


第一个Container.DataItem(0)有一个我需要的ID号

解压缩并发送到存储过程。我该如何提取

dataItem。香港专业教育学院能够循环抛出转发器项目中的项目

并提取整行。我试图将该信息转换为

DataBoundLiteralControl并从中提取文本。但是当我试图使用字符串函数拉取ID号或甚至得到一个长度为
字符串时,我无法始终得到我需要的东西。我发现

行用< html>编码表格和行标签。因此,我回到尝试

来从第一个container.dataitem获取数据。所以,为了做更长的

请求,我会使用什么对象或类来从项目中提取个别的
数据项。我查看了来自

repeateritem类的dataitem属性,但我无法让它工作。再次,thx为

帮助。
thx again for the help martin. i was able to use your suggestion to
get to the control within the repeater. also, i was able to understand
a bit more bout objects, events and arguments. but, im sure i have a
lot to more to learn.

if u or someone else can help me with another question, please do.

i have a repeater pulling job information from a database. each
repeater itemtemplate has with a linkbutton and a row with a label
(for now).

<asp:repeater ID="EmployeeInfo" OnItemCommand="getActivityList"
runat="server">

<itemtemplate>
<tr bgcolor="#CCCCCC">
<td><%# Container.DataItem(0)%></td>
<td><%# Container.DataItem(1)%></td>
<td><%# Container.DataItem(2)%></td>
<td><%# Container.DataItem(3)%></td>
<td><%# Container.DataItem(4)%></td>
<td><asp:linkbutton Text=<%# Container.DataItem(5)%>
runat="server"/></td>
</tr>
<tr>
<td><asp:label id="litLabel" Runat="Server" Text="labelti"
Visible="false"/></td>
</tr>
</itemtemplate>

when u click on the linkbutton, the label(eventually it will be a
placeholder with more database info in another repeater) will become
visible with detailed info bout the job.

the first Container.DataItem(0) has an ID number that I need to
extract and send to the stored procedure. how can i extract that
dataItem. ive been able to loop throw the items in the repeater item
and extract the entire row. i tried to convert that info to a
DataBoundLiteralControl and pull the text from it. but when i tried to
use string functions to pull the ID number or even get a length of
string i could not consistently get what i needed. i figured out that
row is coded with <html> table and row tags. thus, im back to trying
to get the data from the first container.dataitem. so, to make a long
request even longer, what object or class do i use to pull individual
dataitems from an item. i looked at the dataitem property from
repeateritem class, but i cant get it to work. again, thx for the
help.


这篇关于从代码隐藏文件中访问Repeater内部的Control的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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