Click here to Skip to main content
15,902,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am working on rdlc report , i am using following code
C#
var SecBeat1 = _service.GetBeatBySector_Id(sectorId).Count();
         for (int i = 1; i <= SecBeat1; i++)
         {
             var bs = _service.GetAllBeatStatus().Where(x => x.Date == dt && x.Sector_Id == sectorId && x.Shift == 1).FirstOrDefault();
               if(bs!=null)
                 {
                     Employee emp = _service.GetEmployee(bs.Employee_Id);
                     Beat beat = beats.FirstOrDefault(x => x.Id == bs.Beat_Id && x.Sector_Id == sectorId);
                     dataset.Beat.Rows.Add(beat.Name,
                      emp.Name,
                      emp.Id,
                      emp.CellNo
                         // bs.HasWireless
                      );

                 }

                     else
                     {

                             dataset.Beat.Rows.Add("", "", "");


                     }

        }

there are a no of beats in the sector,i have show all all beats of the sector,then if employee are availbale against each beats then employee will be show up ,and if
Posted
Updated 12-Mar-15 19:44pm
v2
Comments
Sinisa Hajnal 12-Mar-15 7:26am    
And what happens instead? You don't get any rows?

Your else will cause an exception if ever bs is null because you're checking if bs!=null and in else it will be null and you're trying to use in foreach.
Sajid227 13-Mar-15 1:45am    
i have update the code ,i just want that when all employee against all beats fill up ,then it will move to else statement,
Sinisa Hajnal 13-Mar-15 2:49am    
Did you consider changing GetAllBeatStatus and GetEmployee so that one returns employeeId = 0 and the other returns some default empty employee when it gets zero as parameter? That way you wouldn't have to check anything, you'd just show whatever comes...and you would know that no employee safely returns empty value.
Sajid227 13-Mar-15 3:19am    
yes, i want to show total row base on beats,there is emp available, then it show up otherwise blank row show up??is there any method ?
Sinisa Hajnal 13-Mar-15 3:39am    
As I said, change GetEmployee method so that it returns blank employee (that is, name = "" etc) if some default id is passed (0?)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900