Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Use of "Repeater" control to loop through data rows

Reply
Thread Tools

Use of "Repeater" control to loop through data rows

 
 
donnet
Guest
Posts: n/a
 
      01-12-2005

I come from J2EE and starting to learn ASP.NET.
I want to find a way to display a web form filled with data taken from a SQL
table. I need to repeat the layout of my web form in one single page, each
time with data taken from the SQL table row. I don't want to put those data
rows into a datagrid because I have my own form that I want to populate with
a specific html layout. And I'm not sure the "Repeater" control is a solution
to my problem.

With J2EE, I would have the use of Java Beans where I would loop and store
each table row information into a class bean and then add each bean into an
ArrayList. Then I would pass this ArrayList to my .JSP page (the equivalent
of .aspx) where I would iterate through my ArrayList to get each bean's
methods using a java scriplet tag to put my "for" loop.

How can i do the equivalent of Java beans in ASP.NET? Can someone give me a
sample codes of the .aspx.cs file and .aspx file showing how you can repeat a
web form and populating with information taken from each table row?

Can I use "Repeater" controls to repeat the display of a web form with
labels, tables, textboxes and textareas and being able to loop through data
rows in order to populate the web form?

Thanks a bunch.
 
Reply With Quote
 
 
 
 
Elmer Carķas
Guest
Posts: n/a
 
      01-13-2005
your best way to do that is use DataList, in the item template of DataList
you put your Html layout with server controls, and use the property
databinding to the controls, to do that you need set the datasource of
datalist, and DataBind the datalist.

The link i put use example with DataRepeater, but you can use same with
DataList
http://www.openmymind.net/databinding/

Elmer Carķas
El Salvador, CA
MSN: http://www.velocityreviews.com/forums/(E-Mail Removed)


"donnet" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> I come from J2EE and starting to learn ASP.NET.
> I want to find a way to display a web form filled with data taken from a

SQL
> table. I need to repeat the layout of my web form in one single page, each
> time with data taken from the SQL table row. I don't want to put those

data
> rows into a datagrid because I have my own form that I want to populate

with
> a specific html layout. And I'm not sure the "Repeater" control is a

solution
> to my problem.
>
> With J2EE, I would have the use of Java Beans where I would loop and store
> each table row information into a class bean and then add each bean into

an
> ArrayList. Then I would pass this ArrayList to my .JSP page (the

equivalent
> of .aspx) where I would iterate through my ArrayList to get each bean's
> methods using a java scriplet tag to put my "for" loop.
>
> How can i do the equivalent of Java beans in ASP.NET? Can someone give me

a
> sample codes of the .aspx.cs file and .aspx file showing how you can

repeat a
> web form and populating with information taken from each table row?
>
> Can I use "Repeater" controls to repeat the display of a web form with
> labels, tables, textboxes and textareas and being able to loop through

data
> rows in order to populate the web form?
>
> Thanks a bunch.



 
Reply With Quote
 
 
 
 
JDP@Work
Guest
Posts: n/a
 
      01-17-2005
Additionally you may wish to consider the following......

Since .Net allows you to use mulitple tables in a result set...

exec usp_GetClient_Order_Summary @clientID

returns....

--table(0)
select accID ,company ,contact ... from contact1 where .....= @someVar

--table(1)
select accID ,orders ,orderID ... from orders where .....= @someVar

--table(2)
select accID ,order_Details ,orderID ... from Order_Det where .....= @someVar


You can bind to these other tables, but not until you bound to table(0)

For example if I want the whole form to be one record and in the center section
display all the invoices and details for each in nested repeaters I must do so
only after the databind for table(0)

'snipit
Private Sub FillForm(ByVal AcctNo As String)

dsOrderSummary = SqlHelper.ExecuteDataset(Common.ConnectionString,
"usp_getOrders", AcctNo)

Me.OrderSummary.DataSource = dsLead.Tables(0)
Me.OrderSummary.DataBind()

dsOrderSummary.Dispose()

End Sub

Private Sub OrderSummary_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
OrderSummary.ItemDataBound

'use public dsOrderSummary dataset to populate inner repeaters
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then

Dim rpt As Repeater = e.Item.FindControl("OrderSummary_Orders")

rpt.DataSource = dsOrderSummary.Tables(1)
rpt.DataBind()

rpt = e.Item.FindControl("OrderSummary_OrderDetail")
rpt.DataSource = dsLead.Tables(2)
rpt.DataBind()

End If
End Sub

As you can see it's tricky but can be done and is an important aspect of using a
repeater to display meaningful data as a full page form.

HTH

JeffP...


"Elmer Carķas" <(E-Mail Removed)> wrote in message
news:uTCavWQ%(E-Mail Removed)...
> your best way to do that is use DataList, in the item template of DataList
> you put your Html layout with server controls, and use the property
> databinding to the controls, to do that you need set the datasource of
> datalist, and DataBind the datalist.
>
> The link i put use example with DataRepeater, but you can use same with
> DataList
> http://www.openmymind.net/databinding/
>
> Elmer Carķas
> El Salvador, CA
> MSN: (E-Mail Removed)
>
>
> "donnet" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >
> > I come from J2EE and starting to learn ASP.NET.
> > I want to find a way to display a web form filled with data taken from a

> SQL
> > table. I need to repeat the layout of my web form in one single page, each
> > time with data taken from the SQL table row. I don't want to put those

> data
> > rows into a datagrid because I have my own form that I want to populate

> with
> > a specific html layout. And I'm not sure the "Repeater" control is a

> solution
> > to my problem.
> >
> > With J2EE, I would have the use of Java Beans where I would loop and store
> > each table row information into a class bean and then add each bean into

> an
> > ArrayList. Then I would pass this ArrayList to my .JSP page (the

> equivalent
> > of .aspx) where I would iterate through my ArrayList to get each bean's
> > methods using a java scriplet tag to put my "for" loop.
> >
> > How can i do the equivalent of Java beans in ASP.NET? Can someone give me

> a
> > sample codes of the .aspx.cs file and .aspx file showing how you can

> repeat a
> > web form and populating with information taken from each table row?
> >
> > Can I use "Repeater" controls to repeat the display of a web form with
> > labels, tables, textboxes and textareas and being able to loop through

> data
> > rows in order to populate the web form?
> >
> > Thanks a bunch.

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
trying to loop through rows in gridview. Paul ASP .Net 2 05-21-2008 06:36 PM
dynamically add new rows and save data typed in these rows to a database Arjen Hoekstra ASP .Net 0 08-02-2005 12:15 PM
help: loop within a loop -how to display data in 3 columns by 4 rows format addi ASP General 0 12-31-2003 04:31 AM
loop through rows in a table Fraggle ASP .Net 3 11-24-2003 04:23 PM



Advertisments