Dificulties using Repeater (new to this control)http://forums.asp.net/t/1778914.aspx/1?Dificulties+using+Repeater+new+to+this+control+Sun, 11 Mar 2012 12:14:37 -040017789144873375http://forums.asp.net/p/1778914/4873375.aspx/1?Dificulties+using+Repeater+new+to+this+control+Dificulties using Repeater (new to this control) Hi, I have a page that shows data from a sql database. The output is to show ID and Name and the Name should be a hyperlink. The list is long so I would like to show as repeated columns. ID. Name. ID. Name. ID. Name I have been used to using Gridview but I think I should be using a Repeater control or data list. I am not sure about the coding for these and the HTML layout language. Seen some notes on Gridview nested in a Repeater but I confess I do not understand the requirements to make it work and layout. Many thanks 2012-03-10T21:47:59-05:004873401http://forums.asp.net/p/1778914/4873401.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) <p>Wouldn't a GridView with paging enabled do the job?</p> 2012-03-10T23:21:14-05:004873409http://forums.asp.net/p/1778914/4873409.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) <p>Hi,</p> <p>Yes I see your point. However I really do not want to have just two columns down page.</p> <p>It would not look quite right. Four colums much better. Thanks</p> <p>&nbsp;</p> 2012-03-10T23:38:13-05:004873414http://forums.asp.net/p/1778914/4873414.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) <p>One of the simple option is design the model accordingly. For eg:</p> <pre class="prettyprint">public class Detail { public int Id1 { get; set; } public string Name1 { get; set; } public int Id2 { get; set; } public string Name2 { get; set; } public int Id3 { get; set; } public string Name3 { get; set; } }</pre> <p>and bind the repeater</p> <pre class="prettyprint">&lt;asp:Repeater ID="Repeater1" runat="server"&gt; &lt;HeaderTemplate&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Id&lt;/td&gt; &lt;td&gt;Name&lt;/td&gt; &lt;td&gt;Id&lt;/td&gt; &lt;td&gt;Name&lt;/td&gt; &lt;td&gt;Id&lt;/td&gt; &lt;td&gt;Name&lt;/td&gt; &lt;/tr&gt; &lt;/HeaderTemplate&gt; &lt;ItemTemplate&gt; &lt;tr&gt; &lt;td&gt;&lt;asp:Label Text='&lt;%# Eval("Id1") %&gt;' runat="server" /&gt; &lt;/td&gt; &lt;td&gt;&lt;asp:HyperLink Text='&lt;%# Eval("Name1") %&gt;' runat="server" /&gt; &lt;/td&gt; &lt;td&gt;&lt;asp:Label ID="Label1" Text='&lt;%# Eval("Id2") %&gt;' runat="server" /&gt; &lt;/td&gt; &lt;td&gt;&lt;asp:HyperLink ID="HyperLink1" Text='&lt;%# Eval("Name2") %&gt;' runat="server" /&gt; &lt;/td&gt; &lt;td&gt;&lt;asp:Label ID="Label2" Text='&lt;%# Eval("Id3") %&gt;' runat="server" /&gt; &lt;/td&gt; &lt;td&gt;&lt;asp:HyperLink ID="HyperLink2" Text='&lt;%# Eval("Name3") %&gt;' runat="server" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;FooterTemplate&gt; &lt;/table&gt; &lt;/FooterTemplate&gt; &lt;/asp:Repeater&gt;</pre> 2012-03-10T23:56:16-05:004873431http://forums.asp.net/p/1778914/4873431.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) <p>Hi,</p> <p>Thanks for that.</p> <p>However, I do not have a database column which shows Id1, Id2, Id3 and Name 1, Name2, Name3.</p> <p>So if I change to my actual headings I get three duplicate columns showing the same data.</p> <p>Of course what I want is the first two colums to show ID 1,2 3, 4 etc with associated names. Then the next two colums to show ID 10,11,12, etc with</p> <p>associated names.</p> <p>Also how do I add an associated lnk url to the hyperlink.</p> <p>I hope this is clear. Many thanks.</p> <p><span size="3" style="font-size:medium"><span size="3" style="font-size:medium"><span lang=""></span></span></span></p> <p></p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> 2012-03-11T00:33:06-05:004873433http://forums.asp.net/p/1778914/4873433.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) <p>You can use NavigateUrl property of HyperLink</p> <pre class="prettyprint">&lt;asp:HyperLink Text='&lt;%# Eval(&quot;Name1&quot;) %&gt;' NavigateUrl=&quot;~/Default.aspx&quot; runat=&quot;server&quot; /&gt;</pre> 2012-03-11T00:42:51-05:004873448http://forums.asp.net/p/1778914/4873448.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) <p>Hi</p> <p>That means you want to display 2 fields in 4 columns isn't it?&nbsp; ( Say&nbsp;values &nbsp;1 to 10 in first 2 columns and 11 to 20 in next 2 columns ?)</p> <p>I don't think it is possible by getting values directly from DB.</p> <p>One possiblity is after getting values displayed in repeater,&nbsp; the cell values are transferred to another &nbsp;table re-arranging the display.</p> <p>&nbsp;</p> <p>B</p> 2012-03-11T01:43:58-05:004873452http://forums.asp.net/p/1778914/4873452.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) <p>Hi,</p> <p>You have want I wish to achieve correctly.</p> <p>&nbsp;</p> <p>I do not know how to transfer cell values to another but I understand your thoughts</p> <p>Thanks</p> <p>&nbsp;</p> 2012-03-11T02:09:40-05:004873468http://forums.asp.net/p/1778914/4873468.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) <p>Another way I think possible is</p> <p>To select odd and even rows of the database&nbsp;AS some 2 different names and bind it to Repeater. Can you try it?</p> <p>I think even and odd rows can be selected in&nbsp;separate statements. I don'tget &nbsp;how to select Odd and Even rows separately in a sigle statement. Try it and inform me if&nbsp; succeed.</p> <p>&nbsp;Good Luck</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> 2012-03-11T02:53:17-05:004873475http://forums.asp.net/p/1778914/4873475.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) <p>I would try to return it in that format from SQL and stick to the GridView, since you said you are familiar with it.</p> <p>Try something like (just make sure it works correctly with uneven number of records.)&nbsp; Depending on what you want to do with it once you have it in the GridView...keep in mind that it would be two SQL records but 1&nbsp;GridView Record</p> <pre class="prettyprint">SELECT A.FullName, A.CreatedOn, B.FullName, B.CreatedOn FROM ( SELECT TOP 50 PERCENT FullName, CreatedOn,ROW_NUMBER() OVER(ORDER BY FullName ASC) AS RowNumber FROM SystemUser ORDER BY FullName ASC ) A LEFT JOIN ( SELECT TOP 50 PERCENT FullName, CreatedOn,ROW_NUMBER() OVER(ORDER BY FullName DESC) AS RowNumber FROM SystemUser ORDER BY FullName DESC ) B ON A.RowNumber = B.RowNumber</pre> 2012-03-11T03:10:06-04:004873489http://forums.asp.net/p/1778914/4873489.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) <p>Hi Basquait</p> <p>won't it show same records in both column in different sort order?</p> <p>can you try somethging like</p> <p>SELECT&nbsp; ID AS 1d1, fullName as fullname1&nbsp;from Table where Mod (id, 2)= 0</p> <p>LEFT JOIN</p> <p>SELECT&nbsp; ID as Id2, fullName as fullname2&nbsp;from Table where Mod (id,2)&lt;&gt; 0</p> <p>&nbsp;</p> <p>provided ID is an identirty column&nbsp;- ineger type</p> <p>&nbsp;</p> <p>.. I am not very falilier with SQL queries.</p> 2012-03-11T03:51:23-04:004873494http://forums.asp.net/p/1778914/4873494.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) Hi No it won&amp;#39;t be the same records. The one list is sorted ASC and the other DESC and then I am only selecting the 1st 50% of each list. Your method is probably better. If there is no ID integer in his table, he could still use my Rownumber 2012-03-11T03:59:07-04:004873501http://forums.asp.net/p/1778914/4873501.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) <p>OK I agree..&nbsp; Thank you for clarifying it.</p> <p>Then Can you please give the complete query if we use the method I suggested.</p> <p>B</p> <p>&nbsp;</p> 2012-03-11T04:08:45-04:004873530http://forums.asp.net/p/1778914/4873530.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) <p>In SQL % is used for MOD. I think it was MOD pre SQL 2005.</p> <p>Assuming there is no incremental integer and we have to create one.</p> <pre class="prettyprint">SELECT *,Row_number () over(ORDER BY Fullname)as RowNumber INTO #TempA FROM ( SELECT Fullname, CreatedON , Row_number () over(ORDER BY Fullname) % 2 AS Remainder FROM SystemUser )xxx WHERE Remainder = 0 SELECT *,Row_number () over(ORDER BY Fullname)as RowNumber INTO #TempB FROM ( SELECT Fullname, CreatedON , Row_number () over(ORDER BY Fullname) % 2 AS Remainder FROM SystemUser )xxx WHERE Remainder &lt;&gt; 0 SELECT #TempA.FullName, #TempA.CreatedOn, #TempB.FullName, #TempB.CreatedOn FROM #TempA FULL OUTER JOIN #TempB ON #TempA.RowNumber = #TempB.RowNumber</pre> 2012-03-11T05:01:23-04:004873706http://forums.asp.net/p/1778914/4873706.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) <p>Will it work</p> <p>Here, there is only one table</p> <p>B</p> <p>&nbsp;</p> 2012-03-11T10:58:05-04:004873763http://forums.asp.net/p/1778914/4873763.aspx/1?Re+Dificulties+using+Repeater+new+to+this+control+Re: Dificulties using Repeater (new to this control) <p>It'll work. I first created 2 Temp tables and then joined them.</p> 2012-03-11T12:14:37-04:00