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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:24:19+00:00 2026-05-24T02:24:19+00:00

I have a Gridview bound to a linqdatasource. The gridview has a FK. i

  • 0

I have a Gridview bound to a linqdatasource. The gridview has a FK. i want to display a name/text field instead of the key field for this column.

I have created a method in my ASP.NET page that basically GetLookupForKey that returns the string when provided the key. However, I don’t know how to send the column data for the specific row in the data declaration.

This should make it clear:

        <asp:TemplateField>
        <ItemTemplate>

        <asp:Literal ID="RoleName" runat="server" Text='<%#

GetRoleName(* I need to send in the RoleId Here*) %>’ />

RoleId is both a boundfield and a DataKeyName. How can I send the RoleId to my method? Additionally, how can I achieve this without using any codebehind?

Thanks

  • 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-24T02:24:19+00:00Added an answer on May 24, 2026 at 2:24 am

    I can see two ways right now, maybe there are even more.

    1) With code behind

    <asp:Literal ID="RoleName" runat="server" Text='<%# GetRoleName(Eval("RoleId")) %>'/>
    

    This one will require a protected method GetRoleName(object roleId) in the page’s code behind class.

    2) Without code behind

    I assume that objects Role and whatever object is referencing it are both declared in the Linq context. If so, Linq can (and even does it by default behavour) generate properties for referenced objects. That is, when you have a table with FK to Role, the corresponding object will have both RoleID and Role properties. Therefore everything can be accomplished declaratively:

    <asp:Literal ID="RoleName" runat="server" Text='<%# Eval("Role.Name") %>'/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have GridView bound to some List. In layout I created following template field:
I have a GridView where one column is bound to an object property containing
I have a gridview control that has on onclick event bound to every cell.
I have a simple application with a GridView bound to a LinqDataSource and a
In my website, I have a gridview which has datasource dynamically bound from database
i think this maybe an easy one... I have a Gridview, bound to a
I have gridview column 'Assignment Result' which is bound to data column status. How
I have a GridView that is bound to an Entity Framework object. I want
I have a gridview that is bound to a sqldatasource. The Gridview only has
I have a GridView which is bound to a datasource, which occasionally has a

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.