{"id":7,"date":"2010-07-08T07:34:32","date_gmt":"2010-07-08T03:34:32","guid":{"rendered":"http:\/\/varietysoftworks.com\/wordpress\/?p=7"},"modified":"2010-07-08T09:01:03","modified_gmt":"2010-07-08T05:01:03","slug":"jquery-asp-net-repeater-server-control","status":"publish","type":"post","link":"http:\/\/varietysoftworks.com\/?p=7","title":{"rendered":"jQuery &#038; Asp.NET Repeater Server Control"},"content":{"rendered":"<p style=\"text-align: justify;\">I&#8217;m probably the last person on earth to discover this, but it is definitely cool&#8230;.<\/p>\n<p style=\"text-align: justify;\">While the Gridview (and DataGrid) are powerful tools for displaying data, they carry a bit more heft than is needed frequently.  Often you can acheive superior results with a Listview (or Repeater) with more fine-grained control and less overhead.<\/p>\n<p style=\"text-align: justify;\">In this case I was using a Repeater inherited from previous versions and have not yet attempted a conversion to Listview (and may not ever). The Repeater control offers an alternate row template which could be used for a lot of things.  But mostly it&#8217;s probably used, as we had in this case, to put in alternating row backgrounds.  The problem is that you create an essentially duplicate row code just to change the styling.<\/p>\n<p style=\"text-align: justify;\">Being at that stage in jQuery where if you&#8217;ve just bought a new hammer, every problem looks like a nail&#8230; It occurred to me that I had just seen a jQuery script for this pattern:<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\"><code>$(\"#myTable tr:even\").addClass(\"alternaterowstyle\");<\/code><\/p>\n<p style=\"text-align: justify;\">You can even:<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\"><code>$(\"myTable tr:odd\").addClass(\"rowstyle\");<br \/>\n$(\"#myTable tr:even\").addClass(\"alternaterowstyle\");<br \/>\n<\/code><\/p>\n<p style=\"text-align: justify;\">So, in this case, the Repeater is rendering a table. All that&#8217;s needed is to apply the jQuery on document ready.<\/p>\n<p style=\"text-align: justify;\">Listview should work essentially the same &#8211; haven&#8217;t tried it yet.<\/p>\n<p style=\"text-align: justify;\">By having a single item template, you don&#8217;t wind up with accidental differences between rows.  Or worse, unnoticed differences &#8211; because they never stay unnoticed, do they?<\/p>\n<p style=\"text-align: justify;\">If you are running your control inside an UpdatePanel, it&#8217;s a bit trickier.  But not much &#8211; next post.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m probably the last person on earth to discover this, but it is definitely cool&#8230;. While the Gridview (and DataGrid) are powerful tools for displaying data, they carry a bit more heft than is needed frequently. Often you can acheive &hellip; <a href=\"http:\/\/varietysoftworks.com\/?p=7\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[],"_links":{"self":[{"href":"http:\/\/varietysoftworks.com\/index.php?rest_route=\/wp\/v2\/posts\/7"}],"collection":[{"href":"http:\/\/varietysoftworks.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/varietysoftworks.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/varietysoftworks.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/varietysoftworks.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7"}],"version-history":[{"count":5,"href":"http:\/\/varietysoftworks.com\/index.php?rest_route=\/wp\/v2\/posts\/7\/revisions"}],"predecessor-version":[{"id":12,"href":"http:\/\/varietysoftworks.com\/index.php?rest_route=\/wp\/v2\/posts\/7\/revisions\/12"}],"wp:attachment":[{"href":"http:\/\/varietysoftworks.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/varietysoftworks.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/varietysoftworks.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}