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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:13:19+00:00 2026-06-04T08:13:19+00:00

I’ve been trawling across the web for answers, and maybe it’s a case of

  • 0

I’ve been trawling across the web for answers, and maybe it’s a case of it being more complicated than I expect (or I just don’t understand the solutions), but I am looking for a way to simply delete a selected row from my jqgrid by clicking the trash icon.

Currently my grid is being populated with Linq to SQL data.
Here is my grid:

jQuery("#grid").jqGrid({
                     url: '<%= ResolveUrl("~/Home/GetData") %>',
                     datatype: "json",
                     mtype: 'GET',
                     postData: { DDLid: function () { return jQuery("#DDL option:selected").val(); } },
                     colNames: ['Col1', 'Col2'],
                     colModel: [
                        { name: 'Col1', index: 'Col1', width: 200, editable: false },
                        { name: 'Col2', index: 'Col2', width: 200, editable: false }
                        ],
                     jsonReader: {
                         repeatitems: false
                     },
                     rowNum: 10,
                     pager: jQuery('#gridpager'),
                     sortname: 'Type',
                     viewrecords: true,
                     sortorder: "asc",
                     caption: "Table"
                 }).navGrid('#gridpager', { del: true, add: false, edit: false, search: false }, {}, {}, {url: "Delete"});

Now the ‘id’ in post data is NOT the primary key in this table – I just need it to help populate the grid.
What I would like to get is the selected row id and pass it to the Delete method, but I can’t find any way to do that.

I have tried using jQuery("#grid").getGridParam('selrow') in the postData but it always returns null.

Any help would be greatly appreciated.

Here is my delete method, for reference:

[AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Delete(int DDLid) 
    {
        int row = Convert.ToInt32(/*I NEED THIS ID*/);
        var query = from x in _ctx.DataTable
                    where ((x.id == row))
                    select x;
        _ctx.DataTable.DeleteOnSubmit(query.Single());
        _ctx.SubmitChanges();
        return Json(true);
    }

This method is called and is fine, but I am getting the wrong id. I need the selected row’s id. This breaks because the DDLid returns more than one row (since it is used to populate the grid).

I hope that makes sense.

  • 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-06-04T08:13:20+00:00Added an answer on June 4, 2026 at 8:13 am

    I discovered where I would pass the selected index (but then I realised I was looking for the primary key, rather than selected index, but it is the same result regardless)

    I needed to add this to my navGrid:

     {url: "Delete", mtype: "POST", reloadAfterSubmit: true, 
           serializeDelData: function (postdata) {
                             var selectedrowindex = jQuery("#grid").jqGrid('getGridParam', 'selrow');
                             var dataFromCellByColumnIndex = jQuery('#grid').jqGrid ('getCell', selectedrowindex , 1); 
                             return {DDLid: postdata.id, name: dataFromCellByColumnIndex};
           }
     });
    

    So this passes a column value to my delete method as well as the DDLid, but I could easily swap dataFromCellByColumnIndex with selectedrowindex.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
Seemingly simple, but I cannot find anything relevant on the web. What is the
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display

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.