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 6596995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:09:06+00:00 2026-05-25T18:09:06+00:00

I have a gridview that is displaying data from a database using LINQ to

  • 0

I have a gridview that is displaying data from a database using LINQ to SQL.

AssetDataContext db = new AssetDataContext();
equipmentGrid.DataSource = db.equipments.OrderBy(n => n.EQCN);

I need to add a column at the end of the girdview that will have links to edit/delete/view the row. I need the link to be “http://localhost/edit.aspx?ID=” + idOfRowItem.

  • 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-25T18:09:07+00:00Added an answer on May 25, 2026 at 6:09 pm

    Try adding a TemplateField to your GridView like so:

    <Columns>
        <asp:TemplateField>
            <ItemTemplate>
                <a href="http://localhost/edit.aspx?ID=<%# DataBinder.Eval(Container.DataItem, "id") %>">Edit</a>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
    

    Within the item template you can place any links you like and bind any data you wish to them from your DataSource. In the example above I have just pulled the value from a column named id.

    As things stand this would work fine, however the column above would be aligned left most in the GridView with all the auto generated columns to its right.

    To fix this you can add a handler for the RowCreated event and move the column to the right of the auto generated columns like so:

    gridView1.RowCreated += new GridViewRowEventHandler(gridView1_RowCreated);
    
    ...
    
    void gridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        GridViewRow row = e.Row;
        TableCell actionsCell = row.Cells[0];
        row.Cells.Remove(actionsCell);
        row.Cells.Add(actionsCell);
    }
    

    Hope this helps.

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

Sidebar

Related Questions

I have a list view that is displaying data using the gridview. This list
I have a gridview that is using a LinqDataSource for it's datasource. I've added
I have a datagrid that is displaying data that is being returned from a
I'm looking to have a GridView displaying Events from a database, and then in
I have a gridview that I have added a checkbox column using a templatefield
I have a Gridview that displays paged results from a search query. The problem
I have gridview that I am using paging on. I want to pass along
I have a GridView that's displaying a bunch of name/value combinations. The name column
I have to create a gridview that is loaded with images from a specific
I have a gridview that could end up displaying about 5K records. I currently

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.