Chris,
seems like there is a little confusion about how the data gets loaded
into the repeater (for instance).
i will take a stab at trying to clarify this ... no guarantees, though
...
here is a sample in the aspx page:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
<asp:Repeater ID=rptCurrentNotices Runat=server>
<ItemTemplate>
<tr>
<td align="left" valign="top" height="94" colspan="2" bgcolor=#e5e5e5>
<span class="bodyhead">
<asp:Label ID=lblNoticeTitle Runat=server><%#
Container.DataItem("EventSubHeader") %></asp:Label>
</span>
<br>
<span class="bodytext">
<asp:Label ID=lblNoticeReleaseDate Runat=server><%#
Format(Container.DataItem("ReleaseDate"),"Long Date") %></asp:Label>
</span>
<br><br>
<span class="bodytext">
<br><asp:Label ID=lblNoticeDesc Runat=server><%#
Container.DataItem("EventDescription") %></asp:Label>
</span>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
this is the vb -Code Behind
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' loadReader is just a custom little function that loads DataReaders
dtrNoticeDescriptions = LoadReader(sSQL, oConn)
rptCurrentNotices.DataSource = dtrNoticeDescriptions
rptCurrentNotices.DataBind()
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
for each row in this repeater, there is an event (itemDataBound
event).
those <%# Container.ItemData("xyz") %> are the items or columns in each
row.
so, the repeater template is really just a way of telling the
ItemDataBound event what goes where.
each ID that you have is unique in the ItemDataBound Event , no need to
track that in your code or manage that dynamically.
for row 1:
the repeater just goes along and puts the lblNoticeTitle for row 1
into the correct place in the template
it puts blNoticeReleaseDate in the correct place and the same for
lblNoticeDesc
then for row 2:
it does the same again.
you basically define the layout/the template/the html objects (or
whatever you want to think of it as) the ITEMTEMPLATE, then the repeater
will loop through and put the data where the itemTemplate tells it to
go.
(coz, for each row, the column names are gonna be the same, you just
need to create the template to tell the data where to go and what kind
of element to bind to).
if you wanted to change how the data is handled you could write code in
the ItemDataBound event.
eg:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub rptCurrentNotices_ItemDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
rptCurrentNotices.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim sEventDesc As String =
Server.HtmlDecode(EnsureStringDefault(DataBinder.Eval(e.Item.DataItem,
"EventDescription")))
Dim lblTitle As Label = e.Item.FindControl("lblNoticeTitle")
Dim lblDesc As Label = e.Item.FindControl("lblNoticeDesc")
lblTitle.Text = DataBinder.Eval(e.Item.DataItem,
"EventSubHeader")
If sEventDesc.Length > 0 Then
lblDesc.Text = sEventDesc
Else
Dim sTmp As String =
Server.HtmlDecode(EnsureStringDefault(DataBinder.Eval(e.Item.DataItem,
"EventText")))
If Len(sTmp) > 500 Then
lblDesc.Text = Left(sTmp, 500) & " ... "
Else
lblDesc.Text = sTmp
End If
End If
End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
i hope this helps. it does get a little wierd at first, but after doing
it for a hot second, it really starts to make more sense.
here are some links that might help.
http://aspalliance.com/cookbook/default.aspx
http://www.w3schools.com/aspnet/default.asp
and by far the best ...
http://www.learnasp.com/freebook/learn
david
>>> [EMAIL PROTECTED] 03/23/2005 3:38:51 PM >>>
Hi all,
in my program, i'm suppose to display all rows that
satisfies my sql query. however, in that sql query, i
have 10 columns and X number or rows. Each row in the
record set should be displayed using textbox, radio,
checkbox, and image button in order for the user to be
able to manipulate the data freely. My problem is how
to display this using Datalist or repeater or datagrid
since the "id" of an object can't be dynamically
generated. Any help will be greatly appreciated.
Thanks.
Chris Andrada
__________________________________
Do you Yahoo!?
Make Yahoo! your home page
http://www.yahoo.com/r/hs
Yahoo! Groups SponsorADVERTISEMENT
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/