Sajid Hussain

Sajid Hussain

  • 1.2k
  • 514
  • 101.5k

how to pass datasource to gridview using loop and condition

Sep 4 2015 2:49 AM
i am using gridview control in my web application,and fill it up using following code.
protected void Page_Load(object sender, EventArgs e)   
      {    
         if (!this.IsPostBack)        
     {         
        this.BindGrid();        
     }       

  }          
 private void BindGrid()        
 {      
       Entities entities = new Entities();       
                      GridView1.DataSource = from customer in entities.DutyPoints.ToList()                                        select customer;           
                   GridView1.DataBind();           
          } 
and aspx code is
<asp:TemplateField HeaderText="Name" ItemStyle-Width="150">         <ItemTemplate>             <asp:Label ID="lblName" runat="server" Text='<%# Eval("Description") %>'></asp:Label>         </ItemTemplate>         <EditItemTemplate>             <asp:TextBox ID="txtName" runat="server" Text='<%# Eval("Description") %>'></asp:TextBox>         </EditItemTemplate> <ItemTemplate>             <asp:Label ID="lblEmp" runat="server" Text='<%# Eval("Employee") %>'></asp:Label>         </ItemTemplate> <asp:dropdownlist id="Employee"></asp:dropdownlist>     </asp:TemplateField> 
it return all list ok,but my requirement is that against each DutyPoint ,there is may be two or three Employees to work on,i want description to display one time if there are more than one employee at that point?
Hide Copy Code
dutyPoint    Employee xxx           Emplist               Emplist               Emplist 
how it is possible?

Answers (2)