ASP.NET repeater alternate row highlighting without full blown

There is no need to manage your own variable (either an incrementing counter or a boolean); you can see if the built-in ItemIndex property is divisible by two, and use that to set a css class: class=”<%# Container.ItemIndex % 2 == 0 ? “” : “alternate” %>” This has the benefit of being completely based … Read more

ASP.NET Repeater bind List

Just use <%# Container.DataItem.ToString() %> If you are worried about null values you may want to refactor to this (.NET 6+) <asp:Repeater ID=”repeater” runat=”server”> <ItemTemplate> <%# Container.DataItem?.ToString() ?? string.Empty%> </ItemTemplate> </asp:Repeater> Note if you are using less than .NET 6 you cannot use the null-conditional operator Container.DataItem?.ToString()

How to find controls in a repeater header or footer

As noted in the comments, this only works AFTER you’ve DataBound your repeater. To find a control in the header: lblControl = repeater1.Controls[0].Controls[0].FindControl(“lblControl”); To find a control in the footer: lblControl = repeater1.Controls[repeater1.Controls.Count – 1].Controls[0].FindControl(“lblControl”); With extension methods public static class RepeaterExtensionMethods { public static Control FindControlInHeader(this Repeater repeater, string controlName) { return repeater.Controls[0].Controls[0].FindControl(controlName); } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)