Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datagrid new line 1

Status
Not open for further replies.

manny1234

IS-IT--Management
Mar 13, 2006
58
US
Is there a way to have one data grid with a line break instead of doing two seperate datagrids?

IE I have a data grid that is too long to display on one line but I do not want to create a seperate datagrid to display it on two lines...
 
u want to make certain columns into rows???

Known is handfull, Unknown is worldfull
 
right I have a column with 8 rows in it. I want to take the last 4 rows and place them in their own column.
 
where is this data coming from, i dont see a direct approach here, u may have to do a lot of manipulation (like adding columns at runtime) etc...

Known is handfull, Unknown is worldfull
 
the data is coming from a sql query.
Code:
Dim UPSCmdText As String = "SELECT name,custid,tracknum,street,city,state,zip,weight,emailaddress,refnumber1,refnumber2,cost,shipopt,returnopt,void,attn,satopt,substring(shipdate,5,2) + '/' + substring(shipdate,7,2) + '/' + substring(shipdate,0,5) as shipdate FROM ups_export WHERE ('" & session("number") & "' + 1000000 = custid)"

Dim UPSCmd As New SQLDataAdapter (UPSCmdText, myConnection)
Dim MDUPSInfo As DataSet
Code:
UPSCmd = New SqlDataAdapter(UPSCmdText, MyConnection)
MDUPSInfo = New DataSet()
myCommand4.Fill(MDUPSInfo,"[ups_export]")
UPSGrid.DataSource = MDUPSInfo.Tables("[ups_export]")
UPSGrid.DataBind

Code:
<asp:DataGrid id="UPSGrid" Font-Size="10" runat="server" autoGenerateColumns="False" CellSpacing="1"  CellPadding="3" BackColor="#efefef" ForeColor="Black" EnableViewState="False">							
            <HeaderStyle font-bold="True" forecolor="black" backcolor="#efefef"></HeaderStyle>
            <ItemStyle backcolor="#efefef"></ItemStyle>
            <columns>
            <asp:HyperLinkColumn
				HeaderText="Tracking Number" 
				DataTextField="TrackNum"
				DataNavigateUrlField="TrackNum"
				DataNavigateUrlFormatString="[URL unfurl="true"]http://wwwapps.ups.com/WebTracking/processRequest?HTMLVersion=5.0&Requester=NES&AgreeToTermsAndConditions=yes&loc=en_US&tracknum={0}"[/URL]
				target="_blank"
				/>
			<asp:BoundColumn
				HeaderText="Ship Date"
				DataField="shipdate"
				/>
			<asp:BoundColumn
				HeaderText="Ship Option"
				DataField="ShipOpt"
				/>
			<asp:BoundColumn
				HeaderText="Description 1"
				DataField="refNumber1"
				/>
			<asp:BoundColumn
				HeaderText="Description 2"
				DataField="RefNumber2"
				/>
			<asp:BoundColumn
				HeaderText="Return Label?"
				DataField="ReturnOpt"
				/>
			<asp:BoundColumn
				HeaderText="Voided?"
				DataField="Void"
				/>	
				</columns>
				</asp:DataGrid>

Wrong datagrid but you get the point
 
lol that was backwards I have a row with 8 columns. I need the last four columns to be in a new row. my bad.
 
but on wht basis must i shift the rows into columns?

u currently have the following structure:
e.g.:

Col1 Col2 Col3
--------------
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1


now from which rows must i create columns? and if i create the columns on wht logic???

Known is handfull, Unknown is worldfull
 
When the sql query is run it will only pull one row of information with 8 columns. I need the last four columns to be in a new row. So two rows of 4 columns.
 
IE

Col1 Col2 Col3 Col4
1 1 1 1

Col5 Col6 Col7 Col8
1 1 1 1
 
but one datagrid can have only one header, so the data will appear like this:

Col1 Col2 Col3 Col4
--------------------
Row1Col1 Row1Col2 Row1Col3 Row1Col4
Row1Col5 Row1Col6 Row1Col7 Row1Col8
Row2Col1 Row2Col2 Row2Col3 Row2Col4
Row2Col5 Row2Col6 Row2Col7 Row2Col8


both Row1 and Row2 data will appear in the same grid (not with seperate headers) is that ok???




Known is handfull, Unknown is worldfull
 
sorry dude, i dont think that is possible :(

Known is handfull, Unknown is worldfull
 
You could do it by grabbing the relevant dat from the ItemDataBound event, creating the relevant HTML and then writing it all out at the end. It's a lot more trouble than it's worth though and far more complicated than simply using a second DataGrid.

Another alternative would be to look at using a DataList and using RepeatColumns property.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top