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!

How to create a sub heading in gridview

Status
Not open for further replies.

taree

Technical User
May 31, 2008
316
US
I am using the below code to create a sub head in my gridview. I would like to display the sub heading but for some reason the link is still appearing in my sub heading rows. can someone help me how to remove the link from my sub heading rows and also how can i merge all the cells in my sub head rows. I have 6 columns in my gridview.


<Columns>

<asp:HyperLinkField DataNavigateUrlFields="contid" DataNavigateUrlFormatString="advdetail.aspx?contid={0}"
Text="View Detail..." >
<ItemStyle Font-Size="Smaller" HorizontalAlign="Left" Wrap="False" Font-Bold="True" Font-Italic="True" />
<HeaderStyle Font-Size="Smaller" HorizontalAlign="Left" />
</asp:HyperLinkField>

<asp:BoundField DataField="Sp" HeaderText="S.P. Number">
<ItemStyle Font-Size="Smaller" HorizontalAlign="Left" Font-Italic="True" Wrap="False" />
<HeaderStyle Font-Size="Smaller" HorizontalAlign="Left" />
</asp:BoundField>

<asp:BoundField DataField="Route Number" HeaderText="Route Number">
<ItemStyle Font-Size="Smaller" HorizontalAlign="Left" Font-Italic="True" Wrap="False" />
<HeaderStyle Font-Size="Smaller" HorizontalAlign="Left" />
</asp:BoundField>

<asp:BoundField DataField="DistrictId" HeaderText="District Name">
<ItemStyle Font-Size="Smaller" HorizontalAlign="Left" Font-Italic="True" Wrap="False" />
<HeaderStyle Font-Size="Smaller" HorizontalAlign="Left" />
</asp:BoundField>

<asp:BoundField DataField="LetDate" HeaderText="Letting Date">
<ItemStyle Font-Size="Smaller" Font-Italic="True" Wrap="False" />
<HeaderStyle Font-Size="Smaller" HorizontalAlign="Left" />
</asp:BoundField>

<asp:BoundField DataField="FULLDESC" HeaderText="Other S.P(s),Route Number, Project Location, Work Type...">
<ItemStyle Font-Size="Smaller" HorizontalAlign="Left" Font-Italic="True" />
<HeaderStyle Font-Size="Smaller" HorizontalAlign="Left" />
</asp:BoundField>

</Columns>


Dim curSect As String = ""
Dim prevSect As String = ""
Dim i As Integer = 0

Do While i <= dsItem.Tables(0).Rows.Count - 1
curSect = dsItem.Tables(0).Rows(i).Item("LetDate")
If curSect <> prevSect Then
prevSect = curSect
Dim AddedRow As DataRow = dsItem.Tables(0).NewRow
AddedRow("Sp") = "Letting Date :" & dsItem.Tables(0).Rows(i).Item("LetDate")
'AddedRow("Sp") = "Letting"
dsItem.Tables(0).Rows.InsertAt(AddedRow, i)
i += 1
End If
i += 1
Loop
 
if you want to alter the html the gridview produces i would recommend just using a repeater and wiring events/data manually. this will be much easier than trying to bend the gridview to your will.

I would also encourage you to use css over inline styling. it's another example of separating the concerns of what data is displayed and how the data is displayed.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top