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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:28:20+00:00 2026-05-27T08:28:20+00:00

I want to use an ObjectDataSource with a GridView in ASP.NET. Displaying the data

  • 0

I want to use an ObjectDataSource with a GridView in ASP.NET. Displaying the data in the GridView works. Now I add a CommandField to the GridView to also enable editing the data. The Update Method works fine, but I have Problems with deleting and inserting:

  1. When I click the Delete link in the GridView, the configured DeleteMethod is called, but with the wrong testSystemEndpoint parameter. Instead of the business object that should be deleted, it is a bare instance with all fields being ‘null’. Therefore the configured DeleteMethod cannot delete the entry.
  2. When I click the Insert link in the GridView nothing happens. The configured InsertMethod is not called.

My ObjectDataSource looks like this:

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
        DataObjectTypeName="[...].TSEndpoint" 
        DeleteMethod="Remove" InsertMethod="Add" 
        OldValuesParameterFormatString="original_{0}" SelectMethod="GetTSEndpoints" 
        TypeName="[...].TSRepository" 
        UpdateMethod="Update"></asp:ObjectDataSource>

My BusinessObject Manager is TSRepository.cs:

[DataObject]
public class TSRepository : ITSRepository
{
    private ISessionFactory _sessionFactory;
    private Configuration _configuration;

    public TSRepository()
    {
        _configuration = new Configuration();
        _configuration.Configure();
        _configuration.AddAssembly(typeof(TSEndpoint).Assembly);
        _sessionFactory = _configuration.BuildSessionFactory();
    }

    [DataObjectMethod(DataObjectMethodType.Insert)]
    public void Add(TSEndpoint testSystemEndpoint)
    {
        if (testSystemEndpoint != null)
        {
            using (ISession session = NHibernateHelper.OpenSession())
            using (ITransaction transaction = session.BeginTransaction())
            {
                session.Save(testSystemEndpoint);
                transaction.Commit();
            }
        }
    }

    [DataObjectMethod(DataObjectMethodType.Update)]
    public void Update(TSEndpoint testSystemEndpoint)
    {
        using (ISession session = NHibernateHelper.OpenSession())
        using (ITransaction transaction = session.BeginTransaction())
        {
            session.Update(testSystemEndpoint);
            transaction.Commit();
        }
    }

    [DataObjectMethod(DataObjectMethodType.Delete)]
    public void Remove(TSEndpoint testSystemEndpoint)
    {
        using (ISession session = NHibernateHelper.OpenSession())
        using (ITransaction transaction = session.BeginTransaction())
        {
            session.Delete(testSystemEndpoint);
            transaction.Commit();
        }
    }

    [DataObjectMethod(DataObjectMethodType.Select)]
    public ICollection<TSEndpoint> GetTSEndpoints()
    {
        using (ISession session = NHibernateHelper.OpenSession())
        {
            var testSystems = session
                .CreateCriteria(typeof(TSEndpoint))                    
                .List<TSEndpoint>();
            return testSystems;
        }
    }
}

I would be very glad if someone could help me with my two problems.

  • 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-27T08:28:21+00:00Added an answer on May 27, 2026 at 8:28 am

    For question 1, I spent the quite a bit of time tracking down a very similar problem in my own code.

    For me, the solution was to set the DataKeyNames property in the gridview to the column name of the Primary Key for my object. Once I did this, everything worked perfectly.

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

Sidebar

Related Questions

I have an ASP.NET GridView that's bound to an ObjectDataSource (which is bound to
I use ListView in asp.net. I get data from provider table. According providerId image
OK, so I understand how to use the ASP.net GridView control's paging. You set
I want to use Javascript Alert function in my ASP.NET page. For example like
I have an ASP.NET 3.5 GridView on a WebForm. The GridView gets data from
I have a generic Repository<T> class I want to use with an ObjectDataSource. Repository<T>
i want use some data from a website with web service. i have a
I want to use Powershell to write some utilities, leveraging our own .NET components
I use ObjectDataSource and bind IEnumerable[Person] to my DevExpress GridView class Person { private
I installed the Asp.net Ajax toolkit. In my site I use the NummericUpDown from

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.