Solved

MVC Capture the selected item id clicked by the user

Posted on 2013-02-06
7
425 Views
Last Modified: 2013-05-05
First time working with MVC.  I've made good progress but I need to know how to handle the issue of capturing a specific row item the user clicked.  The attached EESelected Item_Problem Pic shows the screen.  Obviously there are more items on the screen but for simplicity I showed just one to get the point across.  When the user clicks the 'Execute' it fires the action 'Execute', as seen in the attached Code_Debug_Pic.  I need this action to contain iether the specific item and id the user clicked.  from here I need to look up corosponding records related to the item id.  the issue is how do I capture the item info from the screen when the user clicks it?

If you need more info let me know.
EE-Selected-Item-Problem.bmp
Code-Debug-Pic.bmp
0
Comment
Question by:Steve7423
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 23

Assisted Solution

by:Roopesh Reddy
Roopesh Reddy earned 500 total points
ID: 38862733
Hi,

Are you using WebGrid?

If yes, http://www.dotnetcurry.com/ShowArticle.aspx?ID=655

Hope it helps u...
0
 

Author Comment

by:Steve7423
ID: 38864669
Great link, thanks.  I've got a few things done, but being green with html and views, I now need to pass the selected item to the action link.  here's the code.

 WebGrid grid = new WebGrid(Model.Where(d => d.Disc_Name == discName),selectionFieldName: "selectedRow");
       
                                   
        <pre>@grid.GetHtml(

        fillEmptyRows: false,

        alternatingRowStyle: "alternative-row",

        headerStyle: "grid-header",

        footerStyle: "foot-grid",

        mode: WebGridPagerModes.All,

        firstText: "<< First",

        previousText: "< Previous", nextText: "Next >",

        lastText: "Last >>",



        columns: new[] {  

        grid.Column("Disc_Name",header:"",canSort:false),
        grid.Column("Software", canSort:false),
        grid.Column(  

           "",  

            header: "Action",  

            format: @<text>  

                    @Html.ActionLink("Execute",   "Execute")  
                     @Html.ActionLink("Execute",   "Execute", grid.selectedrow)  


                    </text>  

                    )
                     
         })
         
         

You'll notice I've added the grid.selectedrow to the ActionLink above.  I have no idea if this is correct or how it should be done.
0
 

Accepted Solution

by:
Steve7423 earned 0 total points
ID: 38865263
roopeshreddy:  I got it working

I'd like you to copy the steps below and paste it as a comment, then I'll accept it as the answer.  why because it's important others can learn from this and EE makes it difficult to accept my own answer along with yours, without major hassle.  Ive found it's easier doing this.

1)
Set the grid to selectionfilename = "selectedRow"
Eg: WebGrid grid = new WebGrid(model, selectionFieldName: "selectedRow");

2)
add arguments to the action matching parameters of the action controller Action:
 columns: new[] {  
        grid.Column("Disc_Name",header:"",canSort:false),
        grid.Column("Software", canSort:false),
        grid.Column(  
           "",  
            header: "Action",  
            format: @<text>  
                    @Html.ActionLink("Execute",   "Execute", new {DiscName = item.Disc_Name, Software = item.Software})  
                    </text>  
                    )

3)
Add the parameters to the Action:
public ActionResult Execute(string DiscName, string Software)
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 23

Expert Comment

by:Roopesh Reddy
ID: 38873001
Hi,

So, mark your comment as Answer then!
0
 

Assisted Solution

by:Steve7423
Steve7423 earned 0 total points
ID: 38986208
roopeshreddy: there's a problem with that.  My experience with including myself as an answer initiates the question to be removed, and I don't want to do that.  I want others to learn from what we did.  when I accept my answer the question goes to support for deletion by default.

If you know of a way so i can accept both our solutions without the question being marked for delete then I'm all ears.
0
 
LVL 23

Expert Comment

by:Roopesh Reddy
ID: 38992198
Hi,

In that case, you can assign some points to me with a NOTE to Administrator!!!
0
 

Author Closing Comment

by:Steve7423
ID: 39139160
The steps outlined in my comment show exactly what the problem was so others can combine roopeshreddy's link and my comment, in order to see the connection.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question