如何创建水平中继器?而如何使一个按钮被视为一个图标? [英] How to create a horizontal repeater? And how to make a button be seen as an icon?
问题描述
我使用一个中继器的控制,显示数据表的一些。在中继器中的每一行包含两个culomns:一个图标(红/黄/绿色圆圈)和一个解释
I am using a repeater control that shows data for some table. Each row in the repeater contains two culomns: an icon (red/yellow/green circle) and an explanation.
我要的目标,第一个目标就是只是现在我需要它是水平的,以创建相同的中继器。第二个目标是,我需要每一个图标(红/绿/黄圈)是一个按钮,这样,当我美元的图标一个p $ PSS,事件发生时(什么并不重要,说的Response.Write( 绿色是pressed);
I have to Goals, the first goal is to create the same repeater only now I need it to be horizontal. The second goal is that I need each icon (red/ green/ yellow circle) to be a button so that when I press on one of the icons, an event occurs (doesn't matter what, say Response.Write("Green is Pressed");
你能帮助我吗?
推荐答案
要使其水平,你可以使用里
名单在线
,一个css伎俩。全code为:
To make it horizontal you can use the li
list as inline
, a css trick. The full code for that :
<head runat="server">
<style type="text/css">
#navlist li
{
display: inline;
list-style-type: none;
padding-right: 20px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="navcontainer">
<ul id="navlist">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<li>Some text and my id: <%# GetID(Container.DataItem) %></li>
</ItemTemplate>
</asp:Repeater>
</ul>
</div>
</form>
</body>
</html>
和code背后:
and on code behind:
public partial class Dokimes_StackOverFlow_HorizontialRepeater : System.Web.UI.Page
{
List<int> oMainIds = new List<int>();
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
oMainIds.Add(i);
}
Repeater1.DataSource = oMainIds;
Repeater1.DataBind();
}
public int GetID(object oItem)
{
return (int)oItem;
}
}
和你有一个像渲染:
一些文字,我的ID:0一些文字,我的ID:1一些文字,我的ID:2
一些文字,我的ID:3的一些文字,我的ID:4的一些文字,我的ID:5
一些文字,我的ID:6的一些文字,我的ID:7的一些文字,我的ID:8
一些文字,我的ID:9
Some text and my id: 0 Some text and my id: 1 Some text and my id: 2 Some text and my id: 3 Some text and my id: 4 Some text and my id: 5 Some text and my id: 6 Some text and my id: 7 Some text and my id: 8 Some text and my id: 9
这篇关于如何创建水平中继器?而如何使一个按钮被视为一个图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!