html - How do I create a link in a table that reveals my search results from a count? -
i have 2 sets of data, 1 clients , 1 vacancies of clients. in table have created button when clicked displays client results, includes clientid , client name. have linked in vacancy details manage to tally amount of vacancies have in relation client. right create fourth table header populated links bring user page displays vacancies, instead of tallying them in header. paste code (except data) see if helps. 8th day of coding mvc , still find confusing @ time. if dont want write code, helpful if tell me if need controller, or more models. thank you.
view:
<table> <thead> <tr> <th> reference </th> <th> client name </th> <th> number of vacancies per client </th> <th> link vacancies </th> </tr> </thead> <tbody> <% dim oclient vacancymanager2.datamodels.client each oclient in model.searchresults %> <tr> <td><%: oclient.clientid%></td> <td><%: oclient.clientname%></td> <td><%: oclient.numberofvacancies%></td> <td><%: html.actionlink("the number of vacancies", "indexsearchnumofvacancies", "clientsearch")%></td> </tr> <% next %> </tbody>
controller:
<httpget()> function indexsearch() actionresult dim omodel viewmodels.clientsearch = new viewmodels.clientsearch omodel.searchtext = "" omodel.searchresults = new list(of datamodels.client) return view(omodel) end function <httppost()> function indexsearch(postedinfo formcollection) actionresult dim sclientname = postedinfo("clientname") dim omodel viewmodels.clientsearch = new viewmodels.clientsearch omodel.searchtext = sclientname dim oclientlist datamodels.clientlist = new datamodels.clientlist omodel.searchresults = oclientlist.searchclients(sclientname) return view(omodel) end function
datamodel:
public class client property clientid integer property clientname string public sub new(inclientid integer, inclientname string) me.clientid = inclientid me.clientname = inclientname end sub function numberofvacancies() integer dim ovacancylist vacancylist = new vacancylist return ovacancylist.numberofvacancies(me.clientid) end function end class function searchclients(insearchfor string) list(of client) dim oresults list(of client) = new list(of client) dim oclient datamodels.client each oclient in me.clients if lcase(oclient.clientname).contains(lcase(insearchfor)) oresults.add(oclient) end if next return oresults end function function clientname(inclientid integer) string dim sclientname string = "" dim oclient datamodels.client each oclient in me.clients if oclient.clientid = inclientid sclientname = oclient.clientname exit end if next return sclientname end function
viewmodel:
public class clientsearch property searchtext string property searchresults list(of datamodels.client) end class
Comments
Post a Comment