Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6328553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:28:43+00:00 2026-05-24T17:28:43+00:00

I have a GridView with three databound columns, like this: <Columns> <asp:BoundField HeaderText=Type DataField=Type

  • 0

I have a GridView with three databound columns, like this:

<Columns>
    <asp:BoundField HeaderText="Type" DataField="Type" />
    <asp:BoundField HeaderText="Amenity" DataField="Amenity" />
    <asp:BoundField HeaderText="Distance" DataField="Distance" DataFormatString="{0:0.00} Km" />
</Columns>

Records are sorted by type, and I want to remove the Type column, but then insert a header row for each type when the value of type for the next set of rows changes. How can I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:28:44+00:00Added an answer on May 24, 2026 at 5:28 pm

    This is not the prettiest, but it solves the problem without going outside of the GridView paradigm. Thanks to carlj for Adding (or Inserting) Subheader Rows into a Gridview

    Dim _currentAmenityType = String.Empty
    Protected Sub amenitiesGrid_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles amenitiesGrid.RowDataBound
        If (e.Row.RowType = DataControlRowType.DataRow) Then
            Dim drv = e.Row.DataItem
            If (drv("Type") <> _currentAmenityType) Then
                _currentAmenityType = drv("Type")
                Dim parentTable = TryCast(e.Row.Parent, Table)
                If Not parentTable Is Nothing Then
                    Dim row = New GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal)
                    Dim cell = New TableCell()
                    cell.ColumnSpan = amenitiesGrid.Columns.Count
                    cell.Width = Unit.Percentage(100)
                    cell.Style.Add("font-weight", "bold")
                    cell.Style.Add("background-color", "#c0c0c0")
                    cell.Style.Add("color", "white")
                    Dim span = New HtmlGenericControl("span")
                    span.InnerHtml = _currentAmenityType
                    cell.Controls.Add(span)
                    row.Cells.Add(cell)
                    parentTable.Rows.AddAt(parentTable.Rows.Count - 1, row)
                End If
            End If
        End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridView defined like this: <asp:GridView ID=myGridView ruant=server> <asp:BoundField DataField=myField /> <asp:CommandField
i have a gridview table like this... <div> <asp:GridView ID=GridView1 runat=server AllowSorting=true OnSorting=TaskGridView_Sorting >
I have an ASP.net GridView that spits out three columns of data: ( OrderNumber,
Here is my ASP code: <asp:GridView ID=WagerTable runat=server AutoGenerateColumns=False CssClass=basix > <columns> <asp:BoundField DataField=GameName
I have a gridview like below: <asp:GridView DataKeyNames=TransactionID AllowSorting=True AllowPaging=TrueID=grvBrokerage runat=server AutoGenerateColumns=False CssClass=datatable Width=100%
I have a Datagrid which looks as under <asp:GridView ID=dgTask runat=server Width=100% AutoGenerateColumns=False> <Columns>
I have a GridView control in an Asp.net application, that has a <asp:buttonField> of
I have a GridView that I would like to bind to an ObjectDataSource. I
I have a Gridview boundfield where i set ReadOnly to true because i don't
I have a gridview that contains around 16 ItemTemplate columns. The values in each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.