Solved

How to create a multi column datagrid

Posted on 2004-10-19
6
273 Views
Last Modified: 2010-05-18
I am having a problem figuring out how to create a web page that has a datagrid with 2-3 columns instead of running off the page.  For example:

This is currently what I have:

1223     John Doe
2334     Jane Doe
4432     Jack Doe
3348     Joe Doe

What I would like to have:
1223    John Doe         2334     Jane Doe
4432    Jack Doe         3348     Joe Doe

Two columns will work, but would like 3 columns.

I am using Visual Studio 2003 .net with VB to create a ASP.net page.

Thanks for any assistance
0
Comment
Question by:blouckswwu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12354190
You can manually specify whichever columns you want to show.  Right click on the datagrid then hit property builder, then click on each column and you will see a visible checkbox, uncheck it for the ones you want to hide.

Aeros
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 12355392
u want to have a look at some other controls like the datalist or repeater controls for ur requirement as i am not sure u can very easily acheive what u r trying to do using datagrid ...
0
 
LVL 10

Accepted Solution

by:
jnhorst earned 500 total points
ID: 12355404
Use a DataList instead of the DataGrid.  Set the RepeatColumns property to 2 and RepeatDirection to Horizontal.  Then in the ItemTemplate for the DataList, put a label controls next to each other and bind their text properties to the respective column of the data table that has your data.

John
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:zulu_11
ID: 12356482
using john's idea , use this...

<asp:DataList id="dlMul" runat="server" RepeatColumns="2" RepeatDirection="Horizontal" RepeatLayout="Table">
      <ItemTemplate>
            <asp:Label ID="lblName" Runat="server"><%# DataBinder.Eval(Container.DataItem, "name") %></asp:Label>
            <asp:Label ID="lblNo" Runat="server"><%# DataBinder.Eval(Container.DataItem, "no") %></asp:Label>
      </ItemTemplate>
</asp:DataList>

for my own testing i took a small xml file loaded it into a dataset and then used that as my datasource for the datalist...please modify according to your needs...

Private Sub loadDL()
        Dim objDS As DataSet
        Try
            objDS = New DataSet
            objDS.ReadXml("C:\exex\DL2col.xml")
            dlMul.DataSource = objDS
            dlMul.DataBind()
        Catch ex As Exception
            Response.Write(ex.Message)
        Finally
            If Not objDS Is Nothing Then
                objDS.Dispose()
                objDS = Nothing
            End If
        End Try
    End Sub

Have fun...

Zulu
0
 
LVL 6

Expert Comment

by:zulu_11
ID: 12356486
here's the XML is used

<root>
      <record>
            <name>a</name>
            <no>1</no>
      </record>
      <record>
            <name>b</name>
            <no>2</no>
      </record>
      <record>
            <name>c</name>
            <no>3</no>
      </record>
      <record>
            <name>d</name>
            <no>4</no>
      </record>
      <record>
            <name>e</name>
            <no>5</no>
      </record>
      <record>
            <name>f</name>
            <no>6</no>
      </record>
</root>
0
 

Author Comment

by:blouckswwu
ID: 12357392
Thanks for all the suggestions.  I'll try them and let you know how it goes.

Thanks again!
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question