Solved

How to create a multi column datagrid

Posted on 2004-10-19
6
240 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

758 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

17 Experts available now in Live!

Get 1:1 Help Now