(.NET Newbie) DataGrid killing me !!! (a couple questions)

B

BTHOMASinOHIO

Okay, I'm brand new to .NET and have a Data Grid that is absolutaly
killing me !! I have a couple questions:

1. I have a Web Label and a HTML Table after the DataGrid and in
design it looks great (in FlowLayout), but when viewed (View in
Browser), the label and table are shifted over to the far right side
beside the DataGrid. I tried to put spaces, breaks, but nothing will
move it below to DataGrid where it belongs.
What gives ?!?!

2. How do you combine two headers into one, but still retain the two
columns under the one combined header?

-------------------------------
| Header1 | Header2 | Header3 |
-------------------------------
| 1 | 2 | 3 | 4 |
-------------------------------
| 1 | 2 | 3 | 4 |
-------------------------------
| 1 | 2 | 3 | 4 |
-------------------------------
| 1 | 2 | 3 | 4 |
-------------------------------



3. One of the columns in the DataGrid is a Checkbox, and I need to
make it "Read Only" without making it "shade out" (as in disabled) or
a picture. Any other options ?!


4. I'm going to want to have the user Sort on the Header Column. All
of the examples that I have looked at, say that once the AllowSorting
is set to TRUE then the Heading will turn into a Hyper Link inwhich
you can then asign the "onSortCommand" to some sorting functionality.
Step one doesn't seem to be working for me !! I set the AllowSorting
to true through the GUI or through HTML and neither makes the Header
switch to a hyper link? What have I missed is all the examples ?!?!

Thanks !!
Brent Thomas
Ohio
 
B

BTHOMASinOHIO

(Thanks for the email reply to Question #2 (sorry I deleted your email
already))

Reply to #2:

I followed the example at:
http://www.extremeexperts.com/Net/Articles/ExtendingDataGrid.aspx

.... and it sort of worked. I probably should have explained it a
little better. I have Headers for "Header2" and "Header3" and they are
Sortable (Hypertext button format), underlined, Bold w/Verdanda 10pt
Text and I need to add "Header1", which is a plain old Header (Bold,
Underlined, Verdana 10pt) w/no functionality other then to sit there
and look pretty.

What I thought about doing is to remove the existing Headers and
create all of them with the code bellow, but then I loose all
formatting and functionality.

Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemCreated
If e.Item.ItemType = ListItemType.Footer Then
Dim dgitem As DataGridItem
Dim dgcell As TableCell
Dim dgcell2 As TableCell
Dim dgcell3 As TableCell
Dim dgcell4 As TableCell

dgitem = New DataGridItem(1, 1, ListItemType.Header)
dgcell = New TableCell
dgcell2 = New TableCell
dgcell3 = New TableCell
dgcell4 = New TableCell

dgcell.ColumnSpan = 2
dgitem.Cells.Add(dgcell)
dgcell.Text = "Function"

dgcell2.ColumnSpan = 1
dgitem.Cells.Add(dgcell2)
dgcell2.Text = "Year"

dgcell3.ColumnSpan = 1
dgitem.Cells.Add(dgcell3)
dgcell3.Text = "Service"

dgcell4.ColumnSpan = 1
dgitem.Cells.Add(dgcell4)
dgcell4.Text = "Active"

DataGrid1.Controls(0).Controls.AddAt(0, dgitem)
End If
End Sub


Any ideas ?!?!
TIA
 
B

BTHOMASinOHIO

Replay to Question #2 (again):

A Co-Worker figured it out for me:

I kept the DataGrid Headers and added the following code to span the
first header 2 columns and make the second column invisible.

If e.Item.ItemType = ListItemType.Header Then
e.Item.Cells(0).ColumnSpan = 2
e.Item.Cells(0).HorizontalAlign = HorizontalAlign.Center
e.Item.Cells(0).Width = WebControls.Unit.Pixel(100)
e.Item.Cells(1).Visible = False
End If

(And to think of the time I spent trying to get this to work !!)
:(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top