Link to home
Start Free TrialLog in
Avatar of blouckswwu
blouckswwuFlag for United States of America

asked on

How to create a multi column datagrid

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
Avatar of AerosSaga
AerosSaga

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
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 ...
ASKER CERTIFIED SOLUTION
Avatar of jnhorst
jnhorst

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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>
Avatar of blouckswwu

ASKER

Thanks for all the suggestions.  I'll try them and let you know how it goes.

Thanks again!