Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. hi please help me with a filter on view

hi please help me with a filter on view

Scheduled Pinned Locked Moved .NET (Core and Framework)
helphtmldatabasedebuggingquestion
4 Posts 4 Posters 27 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chrayet Mahdi
    wrote on last edited by
    #1

    hi have a table with email history that when i click on each subject it call external link. my problem is how can i filter my record per Id, because on same table they are a more than same username but with different value cells. on

    @Html.Raw(rec.MailBodyHtml)

    on debug mode i see 5 record for username that's fine but i want filter with primary key of the table on sql. note the primary key on table have no relation with other id . this is my code on view side :

                        [Imprimer](#) 
                            
                        
                    
    
                    
    
                        @foreach (var rec in Model)
    
                        {
                            @Html.Raw(rec.MailBodyHtml)
                        }
                    
    
                
    
            
    
        
    
    
    
    
    
    
        
    
            
    
                
                        @{
                            //foreach (var rec in Model.ReceivedAlerts.OrderBy(c => c.Date))
                            //foreach (var rec in Model.ReceivedAlerts.Where(t => t.Email != null))
                            foreach (var rec in Model)
    
                            {
    

    Date

    Sujet

    Nombres

    Nom

    Email

    Type

    @rec.Date.ToString("dd-MM-yy

    C J A 3 Replies Last reply
    0
    • C Chrayet Mahdi

      hi have a table with email history that when i click on each subject it call external link. my problem is how can i filter my record per Id, because on same table they are a more than same username but with different value cells. on

      @Html.Raw(rec.MailBodyHtml)

      on debug mode i see 5 record for username that's fine but i want filter with primary key of the table on sql. note the primary key on table have no relation with other id . this is my code on view side :

                          [Imprimer](#) 
                              
                          
                      
      
                      
      
                          @foreach (var rec in Model)
      
                          {
                              @Html.Raw(rec.MailBodyHtml)
                          }
                      
      
                  
      
              
      
          
      
      
      
      
      
      
          
      
              
      
                  
                          @{
                              //foreach (var rec in Model.ReceivedAlerts.OrderBy(c => c.Date))
                              //foreach (var rec in Model.ReceivedAlerts.Where(t => t.Email != null))
                              foreach (var rec in Model)
      
                              {
      

      Date

      Sujet

      Nombres

      Nom

      Email

      Type

      @rec.Date.ToString("dd-MM-yy

      C Offline
      C Offline
      Cgkoot
      wrote on last edited by
      #2

      Goa call girls
      Chennai call girls
      Chandigarh call girls
      Dehradun call girls
      Faridabad call girls
      Jaipur call girls
      Shimla call girls
      Mumbai call girls
      Kolkata call girls
      Lucknow call girls
      Noida call girls
      Hyderabad call girls
      Delhi call girls
      Ahmedabad call girls
      Zirakpur call girls
      Surat call girls
      Pune call girls
      Mohali call girls
      Bangalore call girls

      1 Reply Last reply
      0
      • C Chrayet Mahdi

        hi have a table with email history that when i click on each subject it call external link. my problem is how can i filter my record per Id, because on same table they are a more than same username but with different value cells. on

        @Html.Raw(rec.MailBodyHtml)

        on debug mode i see 5 record for username that's fine but i want filter with primary key of the table on sql. note the primary key on table have no relation with other id . this is my code on view side :

                            [Imprimer](#) 
                                
                            
                        
        
                        
        
                            @foreach (var rec in Model)
        
                            {
                                @Html.Raw(rec.MailBodyHtml)
                            }
                        
        
                    
        
                
        
            
        
        
        
        
        
        
            
        
                
        
                    
                            @{
                                //foreach (var rec in Model.ReceivedAlerts.OrderBy(c => c.Date))
                                //foreach (var rec in Model.ReceivedAlerts.Where(t => t.Email != null))
                                foreach (var rec in Model)
        
                                {
        

        Date

        Sujet

        Nombres

        Nom

        Email

        Type

        @rec.Date.ToString("dd-MM-yy

        J Offline
        J Offline
        jschell
        wrote on last edited by
        #3

        Chrayet Mahdi wrote:

        how can i filter my record per Id,

        That makes no sense. A record id is unique. You never filter 'on' it. You can either query for it directly or use it, perhaps in a collection to pull records that match each id in that collection. I can't figure out what you want to do. Instead of throwing code I suggest that you figure out how to ask the question in english and ask for an algorithm (steps) to solve it then write code from that. For example ... 1. You want to present a list of user names. 2. Then a user picks a name. 3. That name represents a set/collection of emails in the database. So then how to get from 1 to 3?

        1 Reply Last reply
        0
        • C Chrayet Mahdi

          hi have a table with email history that when i click on each subject it call external link. my problem is how can i filter my record per Id, because on same table they are a more than same username but with different value cells. on

          @Html.Raw(rec.MailBodyHtml)

          on debug mode i see 5 record for username that's fine but i want filter with primary key of the table on sql. note the primary key on table have no relation with other id . this is my code on view side :

                              [Imprimer](#) 
                                  
                              
                          
          
                          
          
                              @foreach (var rec in Model)
          
                              {
                                  @Html.Raw(rec.MailBodyHtml)
                              }
                          
          
                      
          
                  
          
              
          
          
          
          
          
          
              
          
                  
          
                      
                              @{
                                  //foreach (var rec in Model.ReceivedAlerts.OrderBy(c => c.Date))
                                  //foreach (var rec in Model.ReceivedAlerts.Where(t => t.Email != null))
                                  foreach (var rec in Model)
          
                                  {
          

          Date

          Sujet

          Nombres

          Nom

          Email

          Type

          @rec.Date.ToString("dd-MM-yy

          A Offline
          A Offline
          Andre Oosthuizen
          wrote on last edited by
          #4

          Maybe a little late. You want to sort your records by ID, not filter them. To sort the records by Id, you can use 'LINQ' to sort the 'Model' before iterating through it in your foreach loop, assuming Id is a property of the objects in your 'Model' - Sorting Operators: OrderBy & OrderByDescending[^] Your code will look something like -

          @foreach (var rec in Model.OrderBy(r => r.Id))
          {

              @rec.Date.ToString("dd-MM-yyyy hh:ss")
              
                  [@rec.MailSubject](@Url.Action\() 
              
              @rec.Nb
              @rec.NomAlerte
              @rec.Email
              @rec.TypeAlerte
          

          }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups