This topic is locked

Get ID from list page record and use it in a button outside of the grid

7/6/2022 5:46:00 PM
ASPRunner.NET General questions
R
Rajesh author

I need to call a sql server procedure with record ID and current user signed in from an ASPRunner.NET 10.6 list page.

I am creating a list page, and want to capture ID of a record (probably by creating a button on a fake field) and use that ID in a button (replace the SAVE button) outside of the grid. This button will be calling a procedure with parameters ID and Session user from this button.

What could be the best way to achieve this?

Thanks.

T
Tim 7/6/2022

Maybe I'm missing something, but this doesn't make much sense to me. There is no "save" button on a list page, unless you're doing an inline edit/add.

Are you saying that you want to select a record, and then click a button that is at the top of the list grid and use the ID of the selected row? If so, this might help:

https://xlinesoft.com/asprunnernet/docs/update_multiple_records.htm

Instead of creating a button in a fake field, just use the built in checkbox to select the record. But maybe I'm not understanding what you're trying to do.

Tim

R
Rajesh author 7/6/2022

Hi Tim,
Let me rephrase my question.

I am replacing a legacy application which selects only one record out of multiple records from a table(currently only 5 records in that table) on a page which shows up as a radio button, meaning only one record can be selected out of all records. And there is a button on the bottom of the page which calls a stored procedure with the current record ID and the current user logged in.

Here is what I thought could be a solution.

Create a list page on runner and somehow select one record (by creating a button and a click on it), pass on the record ID to a custom button (outside of the grid) and this custom button would call the stored procedure with record ID and current sesion user.

I thought of list page instead of edit because there is nothing being changed in the grid, it is the custom button outside of the grid which calls the stored procedure

Sergey Kornilov admin 7/6/2022

I'm also not sure if the list page here any better than, for instance, an Edit page, with a lookup wizard.

Anyway, there is no need to use a fake field. You can simply add a button to one of the grid's cell and have an easy access to the underlying record data. See code examples in this article.

R
Rajesh author 7/6/2022

Thanks,
I am able to capture the ID of the record but can't pass it on to a button which is outside the grid.
Is there a global or session variable, which I can create to accomplish this?

Sergey Kornilov admin 7/6/2022

Yes, you can use a session variable for data exchange. This is what session variables are for.

I also think that posting a screenshot of that page would be benefetial. We need to understand the relationship between the elements on that page.

R
Rajesh author 7/6/2022

img alt

Sergey Kornilov admin 7/7/2022

It makes more sense but I see two potential issues here

  1. You will have to click the first button first and then the second one. If someone clicks the second button right aay, it won't work.
  2. You placed your session code into a Javascript event. This won't work either, sessions only work on the server.

T
Tim 7/7/2022

How about just using an edit page. On each row there will be an edit button (which you can re-lable however you want) and the edit page could be a popup window that just said something like "Just ran the stored procedure" and would have a "return to list" button. And then in the "Before display" event of the edit page you can run the stored procedure and should be able to get the data you need to pass.

Or, if you wanted to verify before you run the SP, the edit page could have a save button and you could run the SP in the "Before record updated" event and have it "return false".

Or you could have the edit button run the SP and just return to the list page.

The idea is that, with the edit page, you should have access to that row's data and can run the SP without actually editing the DB.

Just a thought.

Thanks,
Tim