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
Solved

How to create a multi column datagrid

Posted on 2004-10-19
6
265 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

839 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