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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:20:14+00:00 2026-05-11T18:20:14+00:00

Well i have a gridview where i have defined the columns on my own

  • 0

Well i have a gridview where i have defined the columns on my own and turned autogenerating off but now i have the problem that i cant access GridView.SelectedRow.DataItem.

As it turns out to be null now, when it had a value when auto generation was turned on..

Edit:
What i need is a way to save the ID of the row while not showing the ID to the user so if there is any way to 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-11T18:20:15+00:00Added an answer on May 11, 2026 at 6:20 pm

    I’m guessing DataItem is only properly filled when you are using DataBinding.
    Are you using DataBinding?

    Ok from this url:

    The GridView (and actually, all our
    data controls) does not save data
    items across postbacks. This reduces
    ViewState (if the objects are even
    serializable) and enables garbage
    collection to happen and clean up your
    objects. So, when you click the
    button to post back, the GridView has
    not called DataBind and therefore your
    data item isn’t there. This is what
    you’ve discovered.

    Guessing you’re reading the value from a postback, might just be the problem.

    Try using SelectedValue, if you’ve setup the (primary) key for the items.
    I’ve always used that and it worked.
    msdn about SelectedValue

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

Sidebar

Related Questions

Well i have a web page hosted in a IIS 7.0 now the problem
well I have that problem, im using a lightbox srcipt and im opening an
well i have most probably an extremly stupid problem but could not figure it
Well, I have GridView with editable field like 'TemplateField' with DropDownList. My code: <Columns>
I have a gridview that shows records from a database table. Now, I want
I have a ASP.NET GridView that uses template columns and user controls to allow
Well i have a div tag that i show as a modal dialog this
Well I have been writing in the same style for awhile now and all
I have a gridview were I define some columns, like this... <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock
I have a gridview with a template field that has a HyperLink: <asp:TemplateField ItemStyle-Width=12%

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.