在 PRADO 中显示 TdropDownList 中的值
我是 PRADO 新用户,我有一个文件 Home.page 代码:
<%@ Title="Contact List" %>
<h1>Contact List</h1>
<a href="<%= $this->Service->constructUrl('insert')%>">Create New Contact</a>
<br/>
<com:TForm>
<com:TDropDownList ID="personInfo">
<com:TListItem Value="value 1" Text="item 1" />
<com:TListItem Value="value 2" Text="item 2" Selected="true" />
<com:TListItem Value="value 3" Text="item 3" />
<com:TListItem Value="value 4" Text="item 4" />
</com:TDropDownList>
</com:TForm>
& Home.php 的代码
<?php
class Home extends TPage
{
/**
* Populates the datagrid with user lists.
* This method is invoked by the framework when initializing the page
* @param mixed event parameter
*/
public function onInit($param)
{
parent::onInit($param);
// fetches all data account information
$rec = ContactRecord::finder()->findAll();
}
}
?>
$rec 包含所有值的数组。
现在我想在下拉列表中显示所有名称。我尽了最大努力但失败了。 谁能帮助我吗? 谢谢
I m new to PRADO, I have a file
Home.page with code:
<%@ Title="Contact List" %>
<h1>Contact List</h1>
<a href="<%= $this->Service->constructUrl('insert')%>">Create New Contact</a>
<br/>
<com:TForm>
<com:TDropDownList ID="personInfo">
<com:TListItem Value="value 1" Text="item 1" />
<com:TListItem Value="value 2" Text="item 2" Selected="true" />
<com:TListItem Value="value 3" Text="item 3" />
<com:TListItem Value="value 4" Text="item 4" />
</com:TDropDownList>
</com:TForm>
& Home.php with code
<?php
class Home extends TPage
{
/**
* Populates the datagrid with user lists.
* This method is invoked by the framework when initializing the page
* @param mixed event parameter
*/
public function onInit($param)
{
parent::onInit($param);
// fetches all data account information
$rec = ContactRecord::finder()->findAll();
}
}
?>
the $rec contain array of all values.
Now I want to show all name in Dropdown list. I tried my best but fail.
Can anyone help me?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用数据库表列名称填充下拉列表的 DataTextField 和 DataValueField,分别用作 TListItem 的文本和值:
或者,您可以在 HTML 前端中执行此操作:
这样,您只需指定
DataSource
属性并在后端代码中调用DataBind()
方法。You can populate the DataTextField and DataValueField of the dropdownlist with the database table column names to use as the TListItem's text and value respectively:
Alternatively, you can do it in the HTML front-end:
This way, you only need to specify the
DataSource
property and call theDataBind()
method in your back-end code.