初学者关于绑定/格式化转发器的问题 [英] Beginner's question about binding/formatting a repeater

查看:41
本文介绍了初学者关于绑定/格式化转发器的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VB / Dot Net 2.0进行网络应用。我可能有点生疏,我有没有使用转发器控件的经验。


我有一个用户控件我用多个创建属性。我已经创建了一个

测试页面,我已设法将用户控件绑定到转发器并以下列方式显示

一些数据:

< asp:Repeater ID =" Repeater1" RUNAT = QUOT;服务器" DataSourceID =" ObjectDataSource1">

< ItemTemplate>

< uc1:AUserControl runat =" server" SomeField =''<%#Eval(" SomeField")%>''/>

< / ItemTemplate>

< / asp:Repeater> ;


这样可行但是我在

窗口的左边有一行控件。这些控件也由关键字段不均匀地分组。在其他

字样中,我希望看到的是这样的,2维

格式:


AAAAAAA

AAA

BBB

CCCCCC

D


等等。


有没有办法用这种风格格式化转发器?


(我真正喜欢的是与Winform相同的东西'' s

FlowLayoutPanel但我愿意接受一个允许每行固定数量

控制的方案。)

I''m doing a web app in VB/Dot Net 2.0. I''m probably a bit rusty and I have
no experience using the repeater control.

I have a user control I''ve created with multiple properties. I''ve created a
test page and I''ve managed to bind the usercontrol to a repeater and display
some data in the following fashion:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource1">
<ItemTemplate >
<uc1:AUserControl runat="server" SomeField=''<%# Eval("SomeField") %>'' />
</ItemTemplate>
</asp:Repeater>

This works but I get a single line of controls down the left hand of the
window. Also these controls are unevenly grouped by a key field. In other
words, what I would like to see is something like this, a 2 dimensional
formatting:

AAAAAAA
AAA
BBB
CCCCCC
D

and so on.

Is there a way to format a repeater in this style?

(What I would really like is something equivalent to Winform''s
FlowLayoutPanel but I would settle for a scheme that permitted a fixed number
of controls per row.)

推荐答案

当你第一次开始使用Repeater时,它有时会帮助你理解你希望它看起来和向后工作的方式。所有转发器都会为每条记录重复HTML

。所以,如果你知道你想要它的样子,你可以在HTML上查看

并找到它重复的位置。


在你的情况下,你结束转发器做类似的事情:


< td>< uc1:AUserControl runat =" server" SomeField =''<%#Eval(" SomeField")%>''

/>< / td>


您还可以希望它在7次重复后结束,所以你必须使用行

数据绑定并执行以下操作:


// lineCount是你设置的

if((lineCount%7)== 0)

{

//写出< / tr>< tr>

}


注意:您必须将lineCount创建为成员字段,因为您可以从事件参数中获取一些信息,但不是全部。


如果你刚刚切换

控制类型,你也必须在同一事件中计算,因为你想要填充附加行

< td>& nbsp;< / tdbits。类似的东西:


// controlType是你设置的变量,比如lineCount

if(row.ControlType!= controlType)

{

//用足够的< td>& nbsp;< / tdblocks填充行以填充行数7

}


希望这会有所帮助!


-

Gregory A. Beamer

MVP,MCP:+ I,SE ,SD,DBA


订阅我的博客
http://gregorybeamer.spaces.live.com/lists/feed.rss


或者只是阅读它:
http://gregorybeamer.spaces.live.com/


******************************************* *

|创造性思考! |

***************************************** ***

B。 Chernick" < BC ******* @ discussion.microsoft.com写信息

新闻:0A ********************* ************* @ microsof t.com ...
When you first start using the Repeater, it sometimes helps to lay out how
you want it to look and work backwards. All a repeater does is repeat HTML
for each record. So, if you know what you want it to look like, you can look
at the HTML and find where it repeats.

In your case, you end up with the repeater doing something like:

<td><uc1:AUserControl runat="server" SomeField=''<%# Eval("SomeField") %>''
/></td>

You also want it to end after 7 repeats, so you have to use the row
databinding and do something like this:

//lineCount is something you set
if((lineCount%7) == 0)
{
//write out </tr><tr>
}

NOTE: You will have to create lineCount as a member field, as you can get
some info from event args, but not all.

You will also have to figure, in the same event, if you just switched
control types, because you will want to pad out the row with additional
<td>&nbsp;</tdbits. Something like:

//controlType is a variable you set, like lineCount
if(row.ControlType != controlType)
{
//pad row with enough <td>&nbsp;</tdblocks to fill row to 7
}

Hope this helps!

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************
"B. Chernick" <BC*******@discussions.microsoft.comwrote in message
news:0A**********************************@microsof t.com...

我在VB / Dot Net做一个网络应用程序2.0。我可能有点生疏了我



没有使用转发器控件的经验。


我有一个用户我创建了多个属性的控件。我已经创建了

a

测试页面,我设法将用户控件绑定到转发器上并且

显示

以下方式的一些数据:

< asp:Repeater ID =" Repeater1" runat =" server"

DataSourceID =" ObjectDataSource1">

< ItemTemplate>

< uc1:AUserControl runat = "服务器" SomeField =''<%#Eval(" SomeField")%>''

/>

< / ItemTemplate>

< / asp:Repeater>


这样可行,但我在

窗口的左边有一行控件。这些控件也由关键字段不均匀地分组。在

其他

字样中,我希望看到的是这样的,2维

格式:


AAAAAAA

AAA

BBB

CCCCCC

D

等等。


有没有办法用这种风格格式化转发器?


(我会真的喜欢的东西相当于Winform的'

FlowLayoutPanel但是我愿意接受一个允许固定

数的方案

每行控件。)
I''m doing a web app in VB/Dot Net 2.0. I''m probably a bit rusty and I
have
no experience using the repeater control.

I have a user control I''ve created with multiple properties. I''ve created
a
test page and I''ve managed to bind the usercontrol to a repeater and
display
some data in the following fashion:
<asp:Repeater ID="Repeater1" runat="server"
DataSourceID="ObjectDataSource1">
<ItemTemplate >
<uc1:AUserControl runat="server" SomeField=''<%# Eval("SomeField") %>''
/>
</ItemTemplate>
</asp:Repeater>

This works but I get a single line of controls down the left hand of the
window. Also these controls are unevenly grouped by a key field. In
other
words, what I would like to see is something like this, a 2 dimensional
formatting:

AAAAAAA
AAA
BBB
CCCCCC
D

and so on.

Is there a way to format a repeater in this style?

(What I would really like is something equivalent to Winform''s
FlowLayoutPanel but I would settle for a scheme that permitted a fixed
number
of controls per row.)


恐怕我还是有点困惑。起初我以为你写的是

javascript,但看起来你建议在Dot Net代码中输出HTML

组件。 (你正在使用C#。)对吗?


鉴于此,行数据绑定是什么意思?我刚刚做了一点

黑客攻击,我想我可能会做的就是使用Repeater_ItemCreated

事件来达到这个目的。至少它似乎每个控制/记录发射一次。


Cowboy(Gregory A. Beamer)"写道:
I''m afraid I''m still a bit confused. At first I thought you were writing
javascript but it looks like what you are suggesting is outputting HTML
components in Dot Net code. (And you''re using C#.) Right?

Given that, what do you mean by ''row databinding''? I''ve just done a little
hacking and I''m thinking that what I might do is use the Repeater_ItemCreated
event for this purpose. At least it seems to fire once per control/record.

"Cowboy (Gregory A. Beamer)" wrote:

当你第一次开始使用Repeater时,它有时会帮助我们说明你希望它看起来和向后工作的方式。所有转发器都会为每条记录重复HTML

。所以,如果你知道你想要它的样子,你可以在HTML上查看

并找到它重复的位置。


在你的情况下,你结束转发器做类似的事情:


< td>< uc1:AUserControl runat =" server" SomeField =''<%#Eval(" SomeField")%>''

/>< / td>


您还可以希望它在7次重复后结束,所以你必须使用行

数据绑定并执行以下操作:


// lineCount是你设置的

if((lineCount%7)== 0)

{

//写出< / tr>< tr>

}


注意:您必须将lineCount创建为成员字段,因为您可以从事件参数中获取一些信息,但不是全部。


如果你刚刚切换

控制类型,你也必须在同一事件中计算,因为你想要填充附加的行

< td< / tdbits。类似的东西:


// controlType是你设置的变量,比如lineCount

if(row.ControlType!= controlType)

{

//使用足够的< td< / tdblocks来填充行以填充行数7

}


希望这个帮助!


-

Gregory A. Beamer

MVP,MCP:+ I,SE,SD,DBA


订阅我的博客
http://gregorybeamer.spaces.live.com/lists/feed.rss


或只是阅读它:
http://gregorybeamer.spaces.live.com/


********************************************

|创造性思考! |

***************************************** ***

B。 Chernick" < BC ******* @ discussion.microsoft.com写信息

新闻:0A ********************* ************* @ microsof t.com ...
When you first start using the Repeater, it sometimes helps to lay out how
you want it to look and work backwards. All a repeater does is repeat HTML
for each record. So, if you know what you want it to look like, you can look
at the HTML and find where it repeats.

In your case, you end up with the repeater doing something like:

<td><uc1:AUserControl runat="server" SomeField=''<%# Eval("SomeField") %>''
/></td>

You also want it to end after 7 repeats, so you have to use the row
databinding and do something like this:

//lineCount is something you set
if((lineCount%7) == 0)
{
//write out </tr><tr>
}

NOTE: You will have to create lineCount as a member field, as you can get
some info from event args, but not all.

You will also have to figure, in the same event, if you just switched
control types, because you will want to pad out the row with additional
<td</tdbits. Something like:

//controlType is a variable you set, like lineCount
if(row.ControlType != controlType)
{
//pad row with enough <td</tdblocks to fill row to 7
}

Hope this helps!

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************
"B. Chernick" <BC*******@discussions.microsoft.comwrote in message
news:0A**********************************@microsof t.com...

我在VB / Dot Net做一个网络应用程序2.0。我可能有点生疏了我



没有使用转发器控件的经验。


我有一个用户我创建了多个属性的控件。我已经创建了

a

测试页面,我设法将用户控件绑定到转发器上并且

显示

以下方式的一些数据:

< asp:Repeater ID =" Repeater1" runat =" server"

DataSourceID =" ObjectDataSource1">

< ItemTemplate>

< uc1:AUserControl runat = "服务器" SomeField =''<%#Eval(" SomeField")%>''

/>

< / ItemTemplate>

< / asp:Repeater>


这样可行,但我在

窗口的左边有一行控件。这些控件也由关键字段不均匀地分组。在

其他

字样中,我希望看到的是这样的,2维

格式:


AAAAAAA

AAA

BBB

CCCCCC

D

等等。


有没有办法用这种风格格式化转发器?


(我会真的喜欢的东西相当于Winform的'

FlowLayoutPanel但是我愿意接受一个允许固定

数的方案

每行控件。)
I''m doing a web app in VB/Dot Net 2.0. I''m probably a bit rusty and I
have
no experience using the repeater control.

I have a user control I''ve created with multiple properties. I''ve created
a
test page and I''ve managed to bind the usercontrol to a repeater and
display
some data in the following fashion:
<asp:Repeater ID="Repeater1" runat="server"
DataSourceID="ObjectDataSource1">
<ItemTemplate >
<uc1:AUserControl runat="server" SomeField=''<%# Eval("SomeField") %>''
/>
</ItemTemplate>
</asp:Repeater>

This works but I get a single line of controls down the left hand of the
window. Also these controls are unevenly grouped by a key field. In
other
words, what I would like to see is something like this, a 2 dimensional
formatting:

AAAAAAA
AAA
BBB
CCCCCC
D

and so on.

Is there a way to format a repeater in this style?

(What I would really like is something equivalent to Winform''s
FlowLayoutPanel but I would settle for a scheme that permitted a fixed
number
of controls per row.)





你可能想要读这些:

http://aspnet.4guysfromrolla.com/articles/052103- 1.aspx
http:// aspnet .4guysfromrolla.com / articles / 052103-1.aspx


数据列表可能更像是你所追求的,但我有一点点

麻烦辨别你的布局需求。


......


但是中继器也可能是正确的。


中继器提供最大的灵活性,但需要你做最多的工作(经验法则)。


对不起,我不能比这更有帮助。

B。 Chernick" < BC ******* @ discussion.microsoft.com写信息

新闻:0A ********************* ************* @ microsof t.com ...

You might want to read these:

http://aspnet.4guysfromrolla.com/articles/052103-1.aspx
http://aspnet.4guysfromrolla.com/articles/052103-1.aspx

The DataList may be more of what you''re after, but I''m having a little
trouble discerning your layout need.

......

But the Repeater might be correct as well.

The repeater offers the most flexiblity, but requires you to do the most
work (rule of thumb).

Sorry I can''t be more helpful than that.

"B. Chernick" <BC*******@discussions.microsoft.comwrote in message
news:0A**********************************@microsof t.com...

我在VB / Dot Net做一个网络应用程序2.0。我可能有点生疏了我



没有使用转发器控件的经验。


我有一个用户我创建了多个属性的控件。我已经创建了

a

测试页面,我设法将用户控件绑定到转发器上并且

显示

以下方式的一些数据:

< asp:Repeater ID =" Repeater1" runat =" server"

DataSourceID =" ObjectDataSource1">

< ItemTemplate>

< uc1:AUserControl runat = "服务器" SomeField =''<%#Eval(" SomeField")%>''

/>

< / ItemTemplate>

< / asp:Repeater>


这样可行,但我在

窗口的左边有一行控件。这些控件也由关键字段不均匀地分组。在

其他

字样中,我希望看到的是这样的,2维

格式:


AAAAAAA

AAA

BBB

CCCCCC

D

等等。


有没有办法用这种风格格式化转发器?


(我会真的喜欢的东西相当于Winform的'

FlowLayoutPanel但是我愿意接受一个允许固定

数的方案

每行控件。)
I''m doing a web app in VB/Dot Net 2.0. I''m probably a bit rusty and I
have
no experience using the repeater control.

I have a user control I''ve created with multiple properties. I''ve created
a
test page and I''ve managed to bind the usercontrol to a repeater and
display
some data in the following fashion:
<asp:Repeater ID="Repeater1" runat="server"
DataSourceID="ObjectDataSource1">
<ItemTemplate >
<uc1:AUserControl runat="server" SomeField=''<%# Eval("SomeField") %>''
/>
</ItemTemplate>
</asp:Repeater>

This works but I get a single line of controls down the left hand of the
window. Also these controls are unevenly grouped by a key field. In
other
words, what I would like to see is something like this, a 2 dimensional
formatting:

AAAAAAA
AAA
BBB
CCCCCC
D

and so on.

Is there a way to format a repeater in this style?

(What I would really like is something equivalent to Winform''s
FlowLayoutPanel but I would settle for a scheme that permitted a fixed
number
of controls per row.)



这篇关于初学者关于绑定/格式化转发器的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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