Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
This should be simple?
Message
 
 
À
15/10/2012 13:31:15
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01554743
Message ID:
01555044
Vues:
56
>Put the grid in its own div, then load the div content from a partial view when you need it
>
>>I am actually now very close to the final solution!! Just may need a bit more help on jQuery as I almost got it the way I wanted. I just need to figure out how to not load the grid the very first time.
>>
I went with my initial idea as this seems to be easier to me at this point. So, I changed the view to be
<form id="frmClientsSearch">
        
        <label for="clientNo">Client No: </label>
        <input type="number" name="searchClientNo" class="numericOnly" /><br />
        <label for="clientName">Client Name: </label>
        <input type =  "text" size =25 value ="Please enter the search value"
            name ="searchClientName" />
        
       <input type="button" id="btnClientsSearch" value ="Find / Refresh" />      
</form>
and in the Client controller method I now have this code
public ActionResult Client(FormCollection formValues, int? searchClientNo = null, string searchClientName = "Please enter the search value")
        {
            // Assume we want to select everything
            var clients = Db.Clients; // Should set type of clients to IQueryable<Clients>

            if (searchClientNo == null && searchClientName == null)
                clients = clients.Where(c => (c.Number == searchClientNo));
            else
            {
            if ((searchClientNo ?? 0) != 0) //Number was supplied
                clients = clients.Where(c => (c.Number == searchClientNo));

            // If clientNo was supplied, clients is now filtered by that. If not, it still has the full list. The following will further filter it.
            if (!String.IsNullOrWhiteSpace(searchClientName)) // Part of the name was supplied
                clients = clients.Where(c => (c.Name.Contains(searchClientName)));

            }
and so initially the view comes with that text and nothing in the grid and once I put values in the seach controls, they start to work.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform