473,378 Members | 1,122 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Beginner's question about binding/formatting a repeater

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.)
Jul 25 '08 #1
12 2133
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...
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.)
Jul 25 '08 #2
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:
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...
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.)

Jul 25 '08 #3

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...
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.)

Jul 25 '08 #4
Perhaps I should restate this. The group of records has a main key field
(call it pk1). It also has a second subgrouping key (call it pk2). While
all the records have the same pk1, there is no predicting how many will have
any given value of pk2. So you could have 20 records with pk2 = 1, 1 record
with pk2 = 2, 6 records with pk2 = 3, etc. The records have to be displayed
2-dimensionally in their respective subgroups, and using a squarish custom
control that prevents use of more conventional grid layouts.

In any case, If I understood Cowboy correctly, I should insert html into the
page programmatically but I've never done this before and I'm having a hard
time finding the right reference. I've a feeling that I just don't know the
right key word yet. (And putting a
'Page.Response.Output.Write("</tr>test<tr>")' in the ItemCreated event just
puts text at the top of the page.)

Perhaps my real question now is how do I (can I) insert html at a specific
point in the page using the repeater ItemCreated event?
"sloan" wrote:
>
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...
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.)


Jul 25 '08 #5
Pardon for getting past beginner. The short answer is the repeater will not
do the staggered rows, as you desire, by default. If you can have this
format:

AAAAAAA
AAABBBC
CCCCDDD

You can use a DataList instead of a repeater, as it will allow you to
specify a horizontal alignment and put a row break in after 7 items. There
is nothing that natively does this.

AAAAAAA
AAA
BBB
CCCCC
DDD

etc.

You can use a Repeater, but you end up with some code involved. The
information on the repeater class is here:
http://msdn.microsoft.com/en-us/libr....repeater.aspx

With Repeater, the event is ItemDataBound (with many other controls is it
Row data bound), which is here:
http://msdn.microsoft.com/en-us/libr...databound.aspx

this is where you would add the </tr><tr>.

The other event is ItemCreated, which occurs as the item is created. This is
where you have to pad prior to outputting the row.

Yes, this is a bit more complex. If you can live with

AAAAAAA
AAABBBC
CCCCDDD

it is much easier, as you simply use a DataList and set the parameters.

There is nothing I know of that will do precisely what you want in a web
control. There might be a third party control out there that does it,
however.

--
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:83**********************************@microsof t.com...
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:
>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**********************************@microso ft.com...
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.)

Jul 25 '08 #6
The ItemDataBound is useful for injecting code at the end of the event, so
it can be used to end the rows and start a new row.

I will have to delve into ItemCreated, as it is designed to circumvent the
natural coding, so you end up having to put the data back into the item. I
am not sure I will get a chance until later tonight or this weekend, so if
you find an answer, respond back and I will avoid the extra work. :-)

--
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:35**********************************@microsof t.com...
Perhaps I should restate this. The group of records has a main key field
(call it pk1). It also has a second subgrouping key (call it pk2). While
all the records have the same pk1, there is no predicting how many will
have
any given value of pk2. So you could have 20 records with pk2 = 1, 1
record
with pk2 = 2, 6 records with pk2 = 3, etc. The records have to be
displayed
2-dimensionally in their respective subgroups, and using a squarish
custom
control that prevents use of more conventional grid layouts.

In any case, If I understood Cowboy correctly, I should insert html into
the
page programmatically but I've never done this before and I'm having a
hard
time finding the right reference. I've a feeling that I just don't know
the
right key word yet. (And putting a
'Page.Response.Output.Write("</tr>test<tr>")' in the ItemCreated event
just
puts text at the top of the page.)

Perhaps my real question now is how do I (can I) insert html at a specific
point in the page using the repeater ItemCreated event?
"sloan" wrote:
>>
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**********************************@microso ft.com...
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.)


Jul 25 '08 #7

Is a "nested repeater" (or "nested <one of the controls here>") what youre
after?

http://www.codeproject.com/KB/aspnet...Repeaters.aspx

or Google

"nested repeater"
"nested gridview"
"nested datalist"

or similar.

"B. Chernick" <BC*******@discussions.microsoft.comwrote in message
news:35**********************************@microsof t.com...
Perhaps I should restate this. The group of records has a main key field
(call it pk1). It also has a second subgrouping key (call it pk2). While
all the records have the same pk1, there is no predicting how many will
have
any given value of pk2. So you could have 20 records with pk2 = 1, 1
record
with pk2 = 2, 6 records with pk2 = 3, etc. The records have to be
displayed
2-dimensionally in their respective subgroups, and using a squarish
custom
control that prevents use of more conventional grid layouts.

In any case, If I understood Cowboy correctly, I should insert html into
the
page programmatically but I've never done this before and I'm having a
hard
time finding the right reference. I've a feeling that I just don't know
the
right key word yet. (And putting a
'Page.Response.Output.Write("</tr>test<tr>")' in the ItemCreated event
just
puts text at the top of the page.)

Perhaps my real question now is how do I (can I) insert html at a specific
point in the page using the repeater ItemCreated event?
"sloan" wrote:
>>
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**********************************@microso ft.com...
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.)



Jul 25 '08 #8
I design one element (my text boxes, labels etc) and then create a repeater.
I copy and patse that element into the <ItemTemplatetag.
Then I override the Item_DataBound event.
I check if e.item.ItemType is either Item or Alternating Item, and if so I
fill the labels/text boxes etc with data, using database fields.
e.g.
txtFirstName.Text := DataBinder.Eval(e.item.DataItem, 'sFirstName');

Yes that's Delphi :)

I find it all gets a bit mesy when you bind stuff inline on the ASPX page,
especially when you start using nested repeaters and user controls that need
to be loaded dynamically depending on a database field's value.

Hope this helps,
Marc


Jul 25 '08 #9
I don't think so. It looks like what I need to do is simply insert a little
HTML into the page while it's rendering. But I need to know if that's
possible, and most importantly, HOW!

"sloan" wrote:
>
Is a "nested repeater" (or "nested <one of the controls here>") what youre
after?

http://www.codeproject.com/KB/aspnet...Repeaters.aspx

or Google

"nested repeater"
"nested gridview"
"nested datalist"

or similar.

"B. Chernick" <BC*******@discussions.microsoft.comwrote in message
news:35**********************************@microsof t.com...
Perhaps I should restate this. The group of records has a main key field
(call it pk1). It also has a second subgrouping key (call it pk2). While
all the records have the same pk1, there is no predicting how many will
have
any given value of pk2. So you could have 20 records with pk2 = 1, 1
record
with pk2 = 2, 6 records with pk2 = 3, etc. The records have to be
displayed
2-dimensionally in their respective subgroups, and using a squarish
custom
control that prevents use of more conventional grid layouts.

In any case, If I understood Cowboy correctly, I should insert html into
the
page programmatically but I've never done this before and I'm having a
hard
time finding the right reference. I've a feeling that I just don't know
the
right key word yet. (And putting a
'Page.Response.Output.Write("</tr>test<tr>")' in the ItemCreated event
just
puts text at the top of the page.)

Perhaps my real question now is how do I (can I) insert html at a specific
point in the page using the repeater ItemCreated event?
"sloan" wrote:
>
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...
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.)


Jul 25 '08 #10
I believe I've found a solution. How 'elegant' it is is another matter.

The repeater events were no use at all. I put a couple of public variables
into a module and overrode the usercontrol's render routine. At the
beginning, I did a
writer.Write("<Table id='" + tableId + "'>")

Every time that grouping key changes I output
writer.Write("</tr></table><Table>")

I put a <tdaround every control and created a new <trafter every 7
instances.
Since I also stored the max number of records in the module, I output
writer.Write("</table>") at the end.

All tables but the first are set to style='visibility:hidden'. Next step is
to write some Javascript.

"Cowboy (Gregory A. Beamer)" wrote:
The ItemDataBound is useful for injecting code at the end of the event, so
it can be used to end the rows and start a new row.

I will have to delve into ItemCreated, as it is designed to circumvent the
natural coding, so you end up having to put the data back into the item. I
am not sure I will get a chance until later tonight or this weekend, so if
you find an answer, respond back and I will avoid the extra work. :-)

--
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:35**********************************@microsof t.com...
Perhaps I should restate this. The group of records has a main key field
(call it pk1). It also has a second subgrouping key (call it pk2). While
all the records have the same pk1, there is no predicting how many will
have
any given value of pk2. So you could have 20 records with pk2 = 1, 1
record
with pk2 = 2, 6 records with pk2 = 3, etc. The records have to be
displayed
2-dimensionally in their respective subgroups, and using a squarish
custom
control that prevents use of more conventional grid layouts.

In any case, If I understood Cowboy correctly, I should insert html into
the
page programmatically but I've never done this before and I'm having a
hard
time finding the right reference. I've a feeling that I just don't know
the
right key word yet. (And putting a
'Page.Response.Output.Write("</tr>test<tr>")' in the ItemCreated event
just
puts text at the top of the page.)

Perhaps my real question now is how do I (can I) insert html at a specific
point in the page using the repeater ItemCreated event?
"sloan" wrote:
>
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...
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.)

Jul 25 '08 #11
You are one step away from making your own server control (compiled
control), so congratulations. You have gone beyond whee we were taking you,
although the code is still in the ASP.NET code behind. If you move it to a
server control (you do not have to do this now, btw), you will have achieved
a bit of elegance.

I hope this does not sound insincere, as I truly love it when someone thinks
beyond the problem to the solution. And, I am truly happy for you on finding
a solution. :-)

--
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:75**********************************@microsof t.com...
>I believe I've found a solution. How 'elegant' it is is another matter.

The repeater events were no use at all. I put a couple of public
variables
into a module and overrode the usercontrol's render routine. At the
beginning, I did a
writer.Write("<Table id='" + tableId + "'>")

Every time that grouping key changes I output
writer.Write("</tr></table><Table>")

I put a <tdaround every control and created a new <trafter every 7
instances.
Since I also stored the max number of records in the module, I output
writer.Write("</table>") at the end.

All tables but the first are set to style='visibility:hidden'. Next step
is
to write some Javascript.

"Cowboy (Gregory A. Beamer)" wrote:
>The ItemDataBound is useful for injecting code at the end of the event,
so
it can be used to end the rows and start a new row.

I will have to delve into ItemCreated, as it is designed to circumvent
the
natural coding, so you end up having to put the data back into the item.
I
am not sure I will get a chance until later tonight or this weekend, so
if
you find an answer, respond back and I will avoid the extra work. :-)

--
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:35**********************************@microso ft.com...
Perhaps I should restate this. The group of records has a main key
field
(call it pk1). It also has a second subgrouping key (call it pk2).
While
all the records have the same pk1, there is no predicting how many will
have
any given value of pk2. So you could have 20 records with pk2 = 1, 1
record
with pk2 = 2, 6 records with pk2 = 3, etc. The records have to be
displayed
2-dimensionally in their respective subgroups, and using a squarish
custom
control that prevents use of more conventional grid layouts.

In any case, If I understood Cowboy correctly, I should insert html
into
the
page programmatically but I've never done this before and I'm having a
hard
time finding the right reference. I've a feeling that I just don't
know
the
right key word yet. (And putting a
'Page.Response.Output.Write("</tr>test<tr>")' in the ItemCreated event
just
puts text at the top of the page.)

Perhaps my real question now is how do I (can I) insert html at a
specific
point in the page using the repeater ItemCreated event?
"sloan" wrote:
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**********************************@microso ft.com...
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.)

Jul 26 '08 #12
? Excuse me. Terminology question. I thought I was creating a 'server
control'. In any case the user control declaration within the ItemTemplate
of the repeater has the runat="Server" tag.

"Cowboy (Gregory A. Beamer)" wrote:
You are one step away from making your own server control (compiled
control), so congratulations. You have gone beyond whee we were taking you,
although the code is still in the ASP.NET code behind. If you move it to a
server control (you do not have to do this now, btw), you will have achieved
a bit of elegance.

I hope this does not sound insincere, as I truly love it when someone thinks
beyond the problem to the solution. And, I am truly happy for you on finding
a solution. :-)

--
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:75**********************************@microsof t.com...
I believe I've found a solution. How 'elegant' it is is another matter.

The repeater events were no use at all. I put a couple of public
variables
into a module and overrode the usercontrol's render routine. At the
beginning, I did a
writer.Write("<Table id='" + tableId + "'>")

Every time that grouping key changes I output
writer.Write("</tr></table><Table>")

I put a <tdaround every control and created a new <trafter every 7
instances.
Since I also stored the max number of records in the module, I output
writer.Write("</table>") at the end.

All tables but the first are set to style='visibility:hidden'. Next step
is
to write some Javascript.

"Cowboy (Gregory A. Beamer)" wrote:
The ItemDataBound is useful for injecting code at the end of the event,
so
it can be used to end the rows and start a new row.

I will have to delve into ItemCreated, as it is designed to circumvent
the
natural coding, so you end up having to put the data back into the item.
I
am not sure I will get a chance until later tonight or this weekend, so
if
you find an answer, respond back and I will avoid the extra work. :-)

--
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:35**********************************@microsof t.com...
Perhaps I should restate this. The group of records has a main key
field
(call it pk1). It also has a second subgrouping key (call it pk2).
While
all the records have the same pk1, there is no predicting how many will
have
any given value of pk2. So you could have 20 records with pk2 = 1, 1
record
with pk2 = 2, 6 records with pk2 = 3, etc. The records have to be
displayed
2-dimensionally in their respective subgroups, and using a squarish
custom
control that prevents use of more conventional grid layouts.

In any case, If I understood Cowboy correctly, I should insert html
into
the
page programmatically but I've never done this before and I'm having a
hard
time finding the right reference. I've a feeling that I just don't
know
the
right key word yet. (And putting a
'Page.Response.Output.Write("</tr>test<tr>")' in the ItemCreated event
just
puts text at the top of the page.)

Perhaps my real question now is how do I (can I) insert html at a
specific
point in the page using the repeater ItemCreated event?
"sloan" wrote:


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...
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.)



Jul 28 '08 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Donald Williamson | last post by:
I have a DataReader that I am binding to a Repeater control. In the DataReader, I have two fields: 'Name1' and 'Name2' 'Name1' will always have a person's name. Name2 periodically has a person's...
1
by: Pitcairnia | last post by:
We have been using a repeater to spit out images to a page and our seperator is simply a non-breaking space. This is the style we need because it adjusts nicely for the users resolution and width...
0
by: | last post by:
ASP.NET 2.0 simplifies binding datasources to controls like the repeater. These new methods allow nearly code-less mechanisms to dump data to a page. I like this new feature a whole lot. HTML...
4
by: Alan Silver | last post by:
Hello, I'm trying to use an ArrayList to do data binding, but am getting an error I don't understand. I posted this in another thread, but that was all confused with various other problems,...
2
by: ChrisA | last post by:
I have an array of objects I'm binding to a Repeater. Unfortunately, I need to bind to the value returned from a method, while Eval() only seems to work on Properties. Is there a way to do this?...
9
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate>...
3
by: Alex Maghen | last post by:
I'm having trouble with my repeater: I'm binding my Repeater control to an OleDbDataReader object. My ASPX looks like this: <asp:Repeater ID="Rptr" runat="server"> <ItemTemplate> <asp:Label...
4
by: Brad Baker | last post by:
I'm going a little crazy :) I'm trying to bind a repeater control to a dataset on page load using the following code: if (Request.QueryString != null) { string customerid = Request.QueryString;...
5
by: DotNetNewbie | last post by:
Hi, It is not possible to bind a Generic.List collection to a repeater I guess huh? I am getting this error: An invalid data source is being used for rpCategories. A valid data source must...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.