repeater

ASP.NET Repeater Template, Conditional Code for every Nth element

邮差的信 提交于 2019-12-03 10:54:21
I'm using an asp.net repeater to create a bunch of images. The image markup is all the same so the standard <ItemTemplate> is fine. However, I want to wrap K images in a div. Lets say I bind 25+ images to the repeater and I want 5 images per div. How do I go about conditionally creating the start and close tags for the div? Is this a case better suited for a for loop. This should work for you, with no need for anything in the code behind (other than binding the repeater..): <asp:Repeater ID="repImages" runat="server"> <HeaderTemplate><div></HeaderTemplate> <ItemTemplate> <%# (Container

Default text for empty Repeater control

我们两清 提交于 2019-12-03 06:28:18
问题 Using VS 2008, I have a Repeater control: <asp:Repeater runat="server" ID="storesRep" DataSourceID="storeSqlDataSource" OnItemDataBound="StoresRep_ItemDataBound"> <ItemTemplate> <table style="padding:0px"> <tr> <td style="width:200px"><asp:Label ID="infoLbl" runat="server"> Choose stores for upload:</asp:Label>     </td> <td style="width:110px"> <asp:Label ID="storeLbl" runat="server" Text='<%# Bind("Name") %>'> </asp:Label>   </td> <td><asp:CheckBox runat="server" ID="storeCheck" /></td> <

Is it possible to pass a value to the SelectMethod of a Repeater?

谁说我不能喝 提交于 2019-12-03 05:54:15
ASP.Net 4.5 introduces new ways to bind data to controls like the Repeater through the SelectMethod property: <asp:Repeater runat="server" ItemType="MyData.Reference" SelectMethod="GetReferences"> calls the Codebehind method public IEnumerable<Reference> GetReferences() In the scenario of nested repeaters, is it possible to pass a parameter to this select method somehow, so that it fetches different data depending on the Item of the outer repeater? Example: <asp:Repeater runat="server" ItemType="MyData.Reference" SelectMethod="GetReferences(Item.ID)"> should be calling public IEnumerable

how to add sorting function in repeater in asp 2.0?

╄→гoц情女王★ 提交于 2019-12-03 05:04:10
I m using asp 2.0, I need an requirement for sorting the repeater control. I search over the Internet but i could nt find the correct solution. If anyone knows the answer please help to solve my problem. You need to sort the collection before binding to the repeater. If you want to dynamically sort on post backs, sort in the event handler before re-binding to the repeater. This article explains how to add sort functionality to a Repeater or a DataList control. It might help to your purpose or at least as a guide. Finally i got the Sorting output in Repeater Control. 1.Maintaining the Static

Bind dictionary to repeater

霸气de小男生 提交于 2019-12-02 21:42:19
I have a dictionary object <string, string> and would like to bind it to a repeater. However, I'm not sure what to put in the aspx markup to actually display the key-value pair. There are no errors thrown and I can get it to work with a List . How do I get a dictionary to display in a repeater? Joe An IDictionary<TKey,TValue> is also an ICollection<KeyValuePair<TKey, TValue>> . You need to bind to something like (untested): ((KeyValuePair<string,string>)Container.DataItem).Key ((KeyValuePair<string,string>)Container.DataItem).Value Note that the order in which the items are returned is

How to access datasource fields in an ASP.NET Repeaters ItemDataBound event?

爱⌒轻易说出口 提交于 2019-12-02 20:29:27
I have a Repeater control that is being bound to the result of a Linq query. I want to get the value of one of the datasource's fields in the ItemDataBound event, but I'm not sure how to do this. Brian Hedler You can use: e.Item.DataItem . Example: Repeater.ItemDataBound Event // This event is raised for the header, the footer, separators, and items. void R1_ItemDataBound(Object Sender, RepeaterItemEventArgs e) { // Execute the following logic for Items and Alternating Items. if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { if (((Evaluation)e.Item

ASP.NET Repeater Error: No default member found for type xx

我的梦境 提交于 2019-12-02 17:25:24
问题 This is my repeater control in my .aspx page: <asp:Repeater ID="rptEvents" runat="server"> <ItemTemplate> <div><asp:HyperLink ID="hypItem" Text="sss" NavigateUrl="#" runat="server"></asp:HyperLink></div> </ItemTemplate> </asp:Repeater> And this is my codebehind: Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then rptEvents.DataSource = KTOEOS.Agenda.GetAgendaItems // returns a List(Of Agenda) // Where Agenda is my object (created

Error: Procedure or function expects parameter which was not supplied

爷,独闯天下 提交于 2019-12-02 13:17:09
Currently, my program in Visual Studio dynamically adds my data from my Repeater into my database. Now I need to add the ID, my EventId and FormId, which I collected manually outside of the Repeater. I need to add this in: sqlCmd.Parameters.Add("@EventId", SqlDbType.Int).Value = eventId; sqlCmd.Parameters.Add("@FormId", SqlDbType.Int).Value = formId; However with how my code is setup, it gives an error when I add this code that says: Additional information: Procedure or function 'spInsFormRegistrant' expects parameter '@EventId', which was not supplied. Working code (with error code commented

How To Create A Nested LinkButtons Inside A Repeater?

我与影子孤独终老i 提交于 2019-12-02 12:29:48
问题 I need to create a nested linkbuttons in a asp.net page that looks like a treeview, but all are linkbuttons. Example is shown below: ParentLinkButton1 ChildLinkButton1 ChildLinkButton2 ChildLinkButton3 ParentLinkButton2 ChildLinkButton1 ChildLinkButton2 ParentLinkButton3 ParentLinkButton4 ChildLinkButton1 I really don't know how to do this. Based on my research this can be done using repeated control but I don't know how to do that... Please if you can teach me step by step... Thanks in

How can I remove nodes from a SiteMapNodeCollection?

回眸只為那壹抹淺笑 提交于 2019-12-02 10:59:18
问题 I've got a Repeater that lists all the web.sitemap child pages on an ASP.NET page. Its DataSource is a SiteMapNodeCollection . But, I don't want my registration form page to show up there. Dim Children As SiteMapNodeCollection = SiteMap.CurrentNode.ChildNodes 'remove registration page from collection For Each n As SiteMapNode In SiteMap.CurrentNode.ChildNodes If n.Url = "/Registration.aspx" Then Children.Remove(n) End If Next RepeaterSubordinatePages.DataSource = Children The