Normally when you want to do that you are doing it from within an event raised by the DataList. I will assume that is where you are doing this from. Here is a line of code that will get the Text property of the current Item:
If you needed to access this data from a method/function other than one of the events raised by the DataList, you will need to know the index of the item the desired Label is in. In this case, use the following:
Please remember that when accessing data this way you must do it before calling the databind() method in the case of databound properties (it doesn't look like your ItemTemplate has any databound properties, but I assume it will), otherwise it will return a value of “”. Good Luck! — Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
“Arvan” <esato> wrote in message
[news:eiPOPqggGHA.2040@TK2MSFTNGP03.phx.gbl…](news:eiPOPqggGHA.2040@TK2MSFTNGP03.phx.gbl...)
> hi,all.
>
> i placed a datalist named DataList1 and placed a Label named Label1 in
> item template.
>
> how do i get the text of control Label?
>
> code:
>
><datalist id="DataList1" repeatcolumns="4" runat="server"></datalist>> RepeatLayout=”Flow” ShowFooter=”False” ShowHeader=”False”>
><itemtemplate>
><label id="img" runat="server" text="test"></label>> >
></itemtemplate>
>
></esato>
.NET带来的好处之一是所有的源代码和配置文件都是纯文本文件,能够使用Notepad或WordPad等任意的文本编辑器进行编辑。如果不愿意,我们并非一定要使用Visual Studio .NET作为集成开发环境。但使用了Visual Studio .NET,我们可以在Windows文件管理器中看到文件,或在Visual Studio .NET之外从文本编辑器中浏览文件的内容。
使用Visual Studio .NET作为集成开发环境有许多好处,其中最显著的好处是它极大地提高了生产效率。使用Visual Studio. NET,我们能够在付出较小代价的情况下更快地开发软件。作为集成开发环境一部分的IntelliSense提供自动的代码完成、在输入方法或函数时提供动态帮助、语法错误的实时提示,以及其他能够提高生产效率的功能。
象其他复杂的工具那样,在学会如何充分发挥它的作用和掌握其“习性”前,Visual Studio .NET也会使我们产生一种挫折感。有时,它象一个难以了解的黑盒子,会生成大量的文件和许多无用的代码。
Visual Studio .NET的一个功能是,无论是类、控件或表单中的对象,它都能够为新对象提供缺省名字。例如,如果我们创建了一个新的ASP.NET Web Application,其缺省的名字将是WebApplication1。我们可以在“新工程”对话框中方便地改变该应用的名字,但同时改变的只是该应用程序的名字空间的名字及其所在的虚拟目录,源代码文件的缺省名字仍然是WebForm1.aspx和WebForm1.aspx.cs(C#工程)或WebForm1.aspx.vb(VB.NET工程)。
.NET SDK在“启动”菜单上安装一个菜单项,该菜单项能够打开一个正确设置了PATH环境变量的命令提示符窗口。我们可以通过依次点击“开始”->“程序”->“Microsoft Visual Studio .NET”->“Visual Studio .NET工具”->“Visual Studio .NET命令提示符”,启动命令提示符窗口。