0

I want to show database data along these lines:

[row 1 col 1]   [row 1 col 3]
[row 1 col 2]   [row 1 col 4]

[row 2 col 1]   [row 2 col 3]
[row 2 col 2]   [row 2 col 4]

[row 3 col 1]   [row 3 col 3]
[row 3 col 2]   [row 3 col 4]

Etc

Can something like the gridview or repeater controls do this easily or would I have to create custom controls and use them?

Thanks

lucky Len
  • 3
  • 3

1 Answers1

0

Yes you can use Repeater to do that.

ASPX

<form id="Form1" method="post" runat="server">
    <asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>
            <%# DataBinder.Eval(Container.DataItem,"col1") %>   <%# DataBinder.Eval(Container.DataItem,"col3") %>
            <br>
            <%# DataBinder.Eval(Container.DataItem,"col2") %>   <%# DataBinder.Eval(Container.DataItem,"col4") %>
            <br>
        </ItemTemplate>
    </asp:Repeater>
</form>

C#

SqlConnection cnn = new SqlConnection("yourconnection");
SqlDataAdapter da = new SqlDataAdapter("select * from yourtable", cnn);
DataSet ds = new DataSet();
da.Fill(ds, "Temp");
Repeater1.DataSource = ds.Tables["Temp"];
Repeater1.DataBind();
Angus Chung
  • 1,547
  • 1
  • 11
  • 13