Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Repeater OnItemCommand

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RN1 - 01 Mar 2008 14:20 GMT
I have a Repeater control with 2 columns - the data under the 1st
column are links whereas those in the 2nd column are just text.

<script runat="server">
   Sub Page_Load(.......)
       'populating the Repeater & binding the data to it
   End Sub

   Sub Item_Command(ByVal obj As Object, ByVal ea As
RepeaterCommandEventArgs)
       'If (Page.IsPostBack) Then
       '    rptrUsers.DataBind()
       'End If
   End Sub

   Sub Item_DataBound(ByVal obj As Object, ByVal ea As
RepeaterItemEventArgs)
       Response.Write("Data Bound<hr>")
       If (Page.IsPostBack) Then
           rptrUsers.DataBind()
       End If
   End Sub

   Sub Item_Created(ByVal obj As Object, ByVal ea As
RepeaterItemEventArgs)
       Response.Write("Item Created<br>")
   End Sub
</script>

<form runat="server">
<asp:Repeater ID="rptrUsers" OnItemCommand="Item_Command"
OnItemCreated="Item_Created" OnItemDataBound="Item_DataBound"
runat="server">
...................
...................
...................
</asp:Repeater>
</form>

Assuming that the Repeater gets populated with 5 rows, when I run the
above code for the first time, OnItemCreated & OnItemDataBound fires 7
times - once for the header, 5 times for the 5 rows & once for the
footer.

Note the code in the sub named Item_Command which is commented. If I
uncomment the 3 lines & then click a link in the Repeater, the
Repeater no longer gets displayed.

Why so?

Thanks,

Ron
Nathan Sokalski - 01 Mar 2008 22:08 GMT
The reason is because before performing the databinding, you must populate a
DataTable (or whatever you are using as your data source) and assign it to
the Repeater's DataSource property. simply calling the DataBind() method
will pretty much just be binding the Repeater to a DataSource with a value
of Nothing. Hopefully this helps.
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

>I have a Repeater control with 2 columns - the data under the 1st
> column are links whereas those in the 2nd column are just text.
[quoted text clipped - 49 lines]
>
> Ron

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.