I needed to display a list, countries in this case, over two columns. It is relatively simple using record set paging, in its simplest form you count the total rows divide by the number of columns you want then set the page size to the result of that calculation. Then instead of button to scroll through the record set we have a repeater for each page – simples ;-).
1: <div id="CountryList1" style="float:left; width:40%">
2: <asp:Repeater ID="rptCountryList1" runat="server">
3: <ItemTemplate>
4: <li>
5: <a href="Description.aspx?country=<%# DataBinder.Eval(Container.DataItem, "fldCountryID") %>">
6: <%# DataBinder.Eval(Container.DataItem, "fldCountry") %>
7: </a>
8: </li>
9: </ItemTemplate>
10: </asp:Repeater>
11: </div>
12:
13: <div id="CountryList2" style="float:left; width:40%">
14: <asp:Repeater ID="rptCountryList2" runat="server">
15: <ItemTemplate>
16: <li>
17: <a href="Description.aspx?country=<%# DataBinder.Eval(Container.DataItem, "fldCountryID") %>">
18: <%# DataBinder.Eval(Container.DataItem, "fldCountry") %>
19: </a>
20: </li>
21: </ItemTemplate>
22: </asp:Repeater>
23: </div>
1: using System;
2: using System.Web;
3: using System.Web.Security;
4: using System.Web.UI;
5: using System.Web.UI.WebControls;
6: using System.Web.UI.WebControls.WebParts;
7: using System.Web.UI.HtmlControls;
8: using System.Data.SqlClient;
9: using System.Data;
10: using System.Configuration;
11:
12: public partial class page_name : System.Web.UI.Page
13: {
14: SqlConnection scon=new SqlConnection(ConfigurationManager.AppSettings["strConn"]);
15: SqlDataAdapter sDA;
16: DataSet dsCountryList1;
17: DataSet dsCountryList2;
18:
19: const int intPages = 2;
20: int intRows;
21: int rowSum;
22:
23: private void BindData()
24: {
25: rptCountryList1.DataSource = dsCountryList1;
26: rptCountryList1.DataBind();
27: rptCountryList2.DataSource = dsCountryList2;
28: rptCountryList2.DataBind();
29: }
30:
31: private void readpage(int n)
32: {
33: SqlCommand cmd = new SqlCommand("SelectCountriesByLetter", scon);
34: cmd.CommandType = CommandType.StoredProcedure;
35: cmd.Parameters.Add(new SqlParameter("@Product", 10));
36: cmd.Parameters.Add(new SqlParameter("@Letter", "%"));
37: sDA = new SqlDataAdapter(cmd);
38: dsCountryList1 = new DataSet();
39: dsCountryList1.Clear();
40: sDA.Fill(dsCountryList1, 0, intRows, "tblCountry");
41: dsCountryList2 = new DataSet();
42: dsCountryList2.Clear();
43: sDA.Fill(dsCountryList2, intRows, intRows, "tblCountry");
44: }
45:
46: protected void Page_Load(object sender, EventArgs e)
47: {
48: if (!Page.IsPostBack)
49: {
50: SqlCommand cmd = new SqlCommand("SelectCountriesByLetter", scon);
51: cmd.CommandType = CommandType.StoredProcedure;
52: cmd.Parameters.Add(new SqlParameter("@Product", 10));
53: cmd.Parameters.Add(new SqlParameter("@Letter", "%"));
54: sDA = new SqlDataAdapter(cmd);
55: dsCountryList1 = new DataSet();
56: try
57: {
58: sDA.Fill(dsCountryList1, "tblCountry");
59: rowSum = dsCountryList1.Tables[0].Rows.Count;
60: }
61: catch (Exception ex)
62: {
63: rowSum = 0;
64: return;
65: }
66: intRows = rowSum / intPages;
67: readpage(1);
68: BindData();
69: }
70: }
71: }