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

  • SEARCH
  • Home
  • 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 7510741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:19:00+00:00 2026-05-29T23:19:00+00:00

I have some columns being added to a GridView in codebehind. In the actual

  • 0

I have some columns being added to a GridView in codebehind. In the actual .aspx page I have a link field. This works fine, but the link field is showing as the first column and I’d prefer it to be shown as the last (all the way to the right).

Is there a way to specify the order so the link field is on the right? I’m using ASP.NET 4.0.

Here’s my codebehind:

Private Sub loadDynamicGrid()

    Dim connetionString As String
    Dim connection As SqlConnection
    Dim command As SqlCommand
    Dim adapter As New SqlDataAdapter
    Dim ds As New DataSet
    Dim sql As String

    Dim lastName As String
    Dim linkText As String

    lastName = Request.QueryString("lastName")

    connetionString = ConfigurationManager.ConnectionStrings("dbConnectionString").ConnectionString.ToString()
    sql = "SELECT * FROM [EmployeeList] Where [lastname] like '" & lastName & "%' order by lastname"

    connection = New SqlConnection(connetionString)



    Try
        connection.Open()
        command = New SqlCommand(sql, connection)
        adapter.SelectCommand = command
        adapter.Fill(ds)

        'GridView3.Columns.Clear()

        'Build Bound Columns
        Dim curLastName As New BoundField
        curLastName.HeaderText = "Last Name"
        curLastName.DataField = "LastName"
        GridView3.Columns.Add(curLastName)



        Dim curFirstName As New BoundField
        curFirstName.HeaderText = "First Name"
        curFirstName.DataField = "FirstName"
        GridView3.Columns.Add(curFirstName)


        GridView3.Visible = True
        GridView3.DataSource = ds
        GridView3.DataBind()

        adapter.Dispose()
        command.Dispose()
        connection.Close()



    Catch ex As Exception
        MsgBox("Can not open connection ! ")
    End Try



End Sub

And here’s the GridView code:

<asp:GridView id="GridView3" runat="server" AutoGenerateColumns="False"
EmptyDataText="There are no data records to display."
     AllowPaging="True" 
    CssClass="GridViewStyle" GridLines="None" Width="100%">
<Columns>


                            <asp:HyperLinkField DataNavigateUrlFields="EmplID"
                                DataNavigateUrlFormatString="EmployeeProfile.aspx?EmplID={0}"
                                DataTextField="EmplID"
                                DataTextFormatString= "<img src='Images/icons/document-search-result.png' alt='View'/> <u>View</u>" >
                                <ControlStyle CssClass="titleLinksB" />
                            <ItemStyle Wrap="False" />
                            </asp:HyperLinkField>

</Columns>

</asp:GridView>

Thanks for any help!

  • 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-29T23:19:02+00:00Added an answer on May 29, 2026 at 11:19 pm

    Try to use GridView3.Columns.Insert instead of Add. For example:

        GridView3.Columns.Insert(0, curLastName)
    

    On this way the dynamically created columns are added first and the declaratively added columns afterwards.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data frame where columns are constantly being added to it. I
I have jqGrid with two columns, one being hidden. For some reason in FireFox
I have some code here. I recently added this root_id parameter. The goal of
We have some columns with data that must always be in uppercase to ensure
I've got some Columns in a DataGridView that have their Binding property set to
I have some data I am querying. The table is composed of two columns
i have one database, and it contains some columns. My requirement is that how
Lets say I have one row with three columns - some buttons on left
I have a Silverlight app with a DataGrid containing some custom columns and all
i have made columns in some of the tables encrypted in sql server 2008.

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.