Solved

How to create a multi column datagrid

Posted on 2004-10-19
6
250 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
dynamic menu in asp.net c# 11 62
SSRS ReportViewer report timeout 7 104
Error on Add method 1 38
Output Caching in IIS 2 9
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now