repeater

ASP.NET: Bind a value to a custom user control inside a repeater

旧时模样 提交于 2019-12-04 12:51:40
I have an ASP.NET control that binds data to a repeater. Inside that repeater, I have another custom user control. I want to pass a value to this second control based on the current binding item. <asp:Repeater runat="server" ID="ProductList"> <ItemTemplate> <p>Product ID: <%# Eval("ProductID") %></p> <myControl:MyCoolUserControl runat="server" ProductID='<%# Eval("ProductID") %>' /> </ItemTemplate> </asp:Repeater> The repeater item template correctly prints out my Product ID with the Eval statement, but when I do the same thing to pass the Product ID to MyCoolUserControl, it doesn't work (if

ASP.NET DataGrid within a Repeater

岁酱吖の 提交于 2019-12-04 11:08:04
I have a table that has two columns: CommunityID PersonID And A "People" table that has (among other things): FirstName LastName I would like to display a different DataGrid for each community, each datagrid having only the people that are part of that community. I would like to do this without using 4 seperate SqlDataSources. A Repeater looks like a good way, with a DataGrid inside the ItemTemplate, but I can't seem to make heads or tails of getting that to work with the different values for each repetition. If anyone has any suggestions on better ways to do this, I'd be very appreciative, as

DataItem on Repeater.Items is always null

梦想的初衷 提交于 2019-12-04 10:39:30
I am setting the DataSource of my repeater to a List (MyProducts is a simple class, consisting of only get/setters). After this and DataBind(), I can see in debugging mode that DataItem of each Repeater.Items is null. When making a postback and trying to update MyProducts, the Repeater.Items[n].DataItem is still null and Im not able to cast it, to do my work. Why isn't DataItem set on each RepeaterItem, when I databind my repeater? I cant figure/Google it out. Every other aspect of my code works correctly (outputting data from MyProducts to aspx, using for instance: <asp:TextBox runat="server"

asp.net repeater - get value of row item _DataBound

时光怂恿深爱的人放手 提交于 2019-12-04 06:16:20
问题 how can I get the value of each cell that I want in a repeater _DataBound sub? - this is so I can change the value a little and apply the change to a literal 回答1: Let's say this is your repeater (since you didn't include any code): <asp:Repeater ID="_r" runat="server"> <ItemTemplate> <asp:Literal ID="_lit" Text='<%# Eval("yourItemName")%>' runat="server"></asp:Literal> <br /><br /> </ItemTemplate> </asp:Repeater> and you make an ItemDataBound event because you want to add "meow" to the end of

Update Panel and triggers from a repeater control

瘦欲@ 提交于 2019-12-04 05:29:43
Hi I found code similiar to the following online. It's seems really great for getting a button buried in a repeater control to trigger a full cycle back to the server. <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <%=DateTime.Now.ToString() %> </ContentTemplate> <Triggers> <asp:PostBackTrigger ControlID="HiddenButton" /> </Triggers> </asp:UpdatePanel> <!--Make a hidden button to treat as the postback trigger--> <asp:Button ID="HiddenButton" runat="server" Style="display: none" Text="HiddenButton"

How can i do an if statement inside a repeater

拈花ヽ惹草 提交于 2019-12-04 05:22:54
<asp:Repeater> is driving me mad.. I need to do <ItemTemplate> <% if (Container.DataItem("property") == "test") {%> I show this HTML <% } else { %> I show this other HTML <% } %> </ItemTemplate> But I can't for the life of me find any way to make that happen. Ternary isnt any good, because the amount of HTML is quite large, setting labels via a DataBind event is not very good either, as I'd have to have large blocks of HTML in the code-behind. Surely there's a way to do this.... You could try creating a kind of ViewModel class, do the decision on your code-behind, and then be happy with your

Want 10 rows in every page while binding to a repeater

删除回忆录丶 提交于 2019-12-04 05:06:52
问题 I have a repeater which is bound to a data source having 500 rows.I don't want it for paging. Simple when the rows are coming to repeater they grow down.So ,suppose i have 10 pages, each page having 50 rows in the browser print preview, when i am printing the document with ctrl+p command. so,is there any way , so that my page will contain only 10 rows and with header and footer in every page. Thanks Manas 回答1: You can add inside the repeater an if, then, Write call, using also a public

Using an ASP.NET repeater with an array?

半城伤御伤魂 提交于 2019-12-04 00:18:48
This may be a silly question but I was writing a quick test page and realised that I didn't know how to bind an array or ArrayList of strings, for example, to an ASP.NET Repeater. I experimented a bit. <asp:Repeater ID="rptImages" runat="server"> <HeaderTemplate> <h3>Items</h3> </HeaderTemplate> <ItemTemplate> <p style="background-color:Black;color:White"><%#Eval(Container.DataItem.ToString())%></p> </ItemTemplate> <FooterTemplate> <h4>End of Items</h4> </FooterTemplate> </asp:Repeater> Am I being completely stupid? I've only really used it for collections of objects with properties. hoho ...

Access Parent Repeaters DataItem Property

半世苍凉 提交于 2019-12-03 16:11:58
I have a control that has a Repeater, rptReferrals, that runs through a list of Entity objects, Referrals. The Referrals object has a reference to another table called Answers, which is a list of Answers that got submitted for the user. rptReferrals will bind a child repeater, rptQuestionnaire to a List of Questions for the person I am logged in with, which is not connected to the Referrals object it is bound to. Here is the aspx code: <asp:Repeater runat="server" ID="rptReferrals" OnItemDataBound="rptReferrals_OnItemDataBound"> <ItemTemplate> //some HTML for the referral object <asp:Repeater

Angular.js: filter ng-repeat by absence in array

泪湿孤枕 提交于 2019-12-03 12:14:30
I need to filter items in ng-repeat so that only the items which not appear in alreadyAddedValues() array will be shown: <ul class="dropdown-menu"> <li ng-repeat="v in values() | filter: { ????? } ">{{value.name}}</li> </ul> $scope.values() = function(){ ................ } $scope.alreadyAddedValues() = function() { //returns an array } The search of an already added value should perform by value.shortName You can, for example, use a custom function to do the filtering: <li ng-repeat="v in values() | filter:filterAlreadyAdded ">{{value.name}}</li> On the controller: $scope.filterAlreadyAdded =