The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Execute C# snippet from a grids column
Posted: 16 Dec 08 5:42 PM
|
I have a data grid where I want to put a link in that is going to execute a C# snippet that will create a new record in another table based on some of the values in the selected row.
Basically it’s 2-grids side by side. One has list of all kinds of stuff that can be added to the other grid. I want to simply be able to press a link or something in the first grid and go create the record for the other grid in a little C# snippet. Where is the best place to stuff this puppy?
I saw that there is a ‘Row Selection Column’ that highlights the whole row for me, but I don’t see where I can tack on a script.
I tried to use a ‘Link Column’ but it seems like I can only link to another page\entity.
There is a ‘Custom Format Column’ where it looks I can put some code in there, but anytime I try to do something in there I get the following (or similar) error. Invalid token '=' in class, struct, or interface member declaration
--Ken- |
|
|
| |
| |
|
Re: Execute C# snippet from a grids column
Posted: 17 Dec 08 2:44 AM
|
That is a real life saver tip! I used it so many times.
The problem for me is that I am not able to execute the C# snippet when the user presses the link.
The snippet gets executed when the column is filled, so I can't find a way to link a callback to a link/button whatever.
Probably I am missing something really basic, here. Any suggestions?
|
|
|
| |
|
Re: Execute C# snippet from a grids column
Posted: 17 Dec 08 4:45 PM
|
Opps... just saw your post there Alberto and went back to put mine to the test.
Indeed it does fire on the creation of the datagrid and for each row that is in the grid. This is not going to work for me either. I need a way for it just to fire from a link or a button.
In my situation I want to create a record in another table and display the selected items in another grid sitting next to it. So what I get now is every record added to the 2nd grid as soon as I open the form. And then it duplicates the entry every time I F5 the page.
So... Where can I stuff this code where it will only happen when the link is clicked?
Maybe imbed the id in an href kind of like Ryans example and then launch a separate page that does nothing but create the record for that passed id.
Hummm... or could I call a business rule imbedded in the href? It cant be right in the custom format code because we will be right where we are at now with it firing for every row.
I know I'm close because I can see the light at the end of the tunnel (That not train lights I see is it?)
--Ken--
|
|
|
|
Re: Execute C# snippet from a grids column
Posted: 04 Feb 09 7:46 AM
|
Bumping an old post.
In 7.5 you can use the row selection column and the new Row Selection Action to accomplish this.
Basically, you setup a Row Selection Column with the message you want ("Add", "Move", "Whatever"...) and in the Row Selection Action you setup a Snippet. You can use the standard ASP.NET methods (SelectedIndex property) to retrieve the selected row.
Hope it helps. |
|
|
| |
|