In this post, i will tell you about Showing Team Member With Its Team In Gridview Using ASP.NET. This following code snippet is for to show team member with its team in Gridview using ASP.NET:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4"> 
    <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" /> 
    <HeaderStyle BackColor="#990000" Font-Bold="true" ForeColor="#FFFFCC" /> 
    <AlternatingRowStyle BackColor="#DFDFD0" /> 
        <asp:BoundField DataField="Teamname" HeaderText="Teamname" /> 
        <asp:TemplateField HeaderText="Agentname"> 
                <asp:DropDownList ID="ddlagent" runat="server" Width="250px" /> </ItemTemplate> 
        <asp:TemplateField HeaderText="CountAgent"> 
                <asp:Label ID="lblAgent" runat="server" Width="100px" /> </ItemTemplate> 
    <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" /> 
    <RowStyle BackColor="White" ForeColor="#330099" /> 
    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" /> 
    <SortedAscendingCellStyle BackColor="#FEFCEB" /> 
    <SortedAscendingHeaderStyle BackColor="#AF0101" /> 
    <SortedDescendingCellStyle BackColor="#F6F0C0" /> 
    <SortedDescendingHeaderStyle BackColor="#7E0000" />  


using System.Data; 
using System.Data.SqlClient; 
using System.Configuration; 
public partial class Default2: System.Web.UI.Page { 
    string ConnStr = ConfigurationManager.ConnectionStrings["CRMConnectionString"].ToString(); 
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CRMConnectionString"].ToString()); 
    DataSet someDataSet = new DataSet(); 
    SqlDataAdapter adapt = new SqlDataAdapter(); 
    protected void Page_Load(object sender, EventArgs e) { 
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { 
        if (e.Row.RowType == DataControlRowType.DataRow) { 
            var ddl = (DropDownList) e.Row.FindControl("ddlagent"); 
            var Agent = (Label) e.Row.FindControl("lblAgent"); 
            string TeamName = e.Row.Cells[0].Text.ToString(); 
            SqlCommand cmd = new SqlCommand("SELECT distinct (Agentname +' , ' + Hr_id) as [Agentname] FROM CRM_Agentname " + " WHERE TeamName = '" + TeamName + "' and status='Active'", con); 
            SqlDataAdapter da = new SqlDataAdapter(cmd); 
            DataSet ds = new DataSet(); 
            ddl.DataSource = ds; 
            ddl.DataTextField = "Agentname"; 
            ddl.DataValueField = "Agentname"; 
            int totalItems = ddl.Items.Count; 
            Agent.Text = totalItems.ToString(); 
    private void TopTeam() { 
        SqlCommand cmd = new SqlCommand("SELECT DISTINCT TeamName FROM CRM_Teamname where status='ACtive' and process like 'r%' and teamname!='---- Select ----'", con); 
        SqlDataAdapter da = new SqlDataAdapter(cmd); 
        DataSet ds = new DataSet(); 
        GridView1.DataSource = ds; 
} ASP.NET Core 1.0 Hosting

European best, cheap and reliable ASP.NET hosting with instant activation. is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.