Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6628187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:06:05+00:00 2026-05-25T22:06:05+00:00

Everyone. I have a question when combining cells in GridView. I konw how to

  • 0

Everyone.

I have a question when combining cells in GridView. I konw how to combine BoundField cells, but I do not know how to combine TemplateField cells in asp.net GridView.

EDIT:

Perhaps I did not make my question clearly and I am sorry about that. My question is that I use GridView to bind data from db and There is a field named UserName, one user has several records in the db, so I want to combine UserName in one cell(i can combine it correctly). In the same way, I want to do some operation to this user such as Add, Delete. So i put these operations into TemplateField, but i do not konw how to combine TemplateField like BoundField. I have a low reputation, so i can not post images

Any good ideas?

Sorry for my poor english! Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:06:06+00:00Added an answer on May 25, 2026 at 10:06 pm

    There isn’t a way to merge/combine fields. I think you misunderstood the BoundFields/TemplateField. However you can use Eval() and Bind() to show/bind one or more expression into single cell//column..

    Read MSDN articles:

    1. BoundField
    2. TemplateField

    EDIT:

    @loren : There is a field named UserName, one user has several records
    in the db.

    I guess you need to use “nested” grid or you may also use any data control (formview, detail view or ListView).

    Here is demo that shows how to bind nested data controls.

    I’ve define two classes – Contact, Info

    public class Contact
    {
        public string Address{get;set;}
        public string Phone {get;set;}
    }
    public class Info
    {
        public string UserName {get;set;}
        private List<Contact> _addr=new List<Contact>();
        public List<Contact> Address
        {
            get { return _addr; }
            set { _addr = value; }
        }
    }
    

    In .aspx page (Markup),

    <asp:GridView 
        ID="GridView1" 
        runat="server"
        AutoGenerateColumns="false" 
        onrowdatabound="GridView1_RowDataBound"
        >
    <Columns>
    <asp:TemplateField>
    <ItemTemplate>
    <p>
        Username :
        <asp:Literal 
            ID="UserName" 
            runat="server"
            Text='<%#Eval("UserName") %>'
            >
        </asp:Literal>
    </p>
    
    <asp:GridView 
                    ID="GridView2" 
                    runat="server"
                    AutoGenerateColumns="false"
                    >
                    <Columns>
                    <asp:TemplateField>
                    <ItemTemplate>
                        <p>Phone : 
                            <asp:TextBox 
                                runat="server" 
                                ID="txtDetail" 
                                Text='<%#Bind("Phone") %>'
                                ></asp:TextBox>
                        </p>
                    </ItemTemplate>
                    </asp:TemplateField>
                    </Columns>
    </asp:GridView>
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>       
    </asp:GridView>
    

    and in code-behind (aspx.cs),

    List<Info> info;
    protected void Page_Load(object sender, EventArgs e)
    {
     if (!IsPostBack)
     {
        info = new List<Info>()
        {
            new Info()
            {
                    UserName="User1",
                    Address =
                    {
                        new Contact() { Phone="2929927", Address="Address1"},
                        new Contact() { Phone="2929928", Address="Address2"},
                    }
            },
            new Info()
            {
                    UserName="User2",
                    Address =
                    {
                        new Contact() { Phone="2929929", Address="Address3"},
                        new Contact() { Phone="2929930", Address="Address4"},
                    }
            },
    
        };
    
        GridView1.DataSource = info;
        GridView1.DataBind();
      }
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    
        Literal username=(Literal)e.Row.FindControl("UserName");
        GridView view=(GridView)e.Row.FindControl("GridView2");
        if (view != null)
        {
            var result = from ele in info
                        from add in ele.Address
                        where ele.UserName == username.Text
                        select add;
            view.DataSource = result;
            view.DataBind();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good morning everyone, I have a question about J2EE framework. since ASP.net 3.5 mvc
Greetings everyone! Question : does any one have a success with combining Microsoft Visual
everyone I have some question about tasks in Linux, I know that all tasks
I'm currently toying with asp.net mvc3 and have a question with respect to models
Now I do have a hw question for everyone...I've been staring at this for
Hey everyone, here is the site in question: http://www.myvintagesecret.com/ I have a bunch of
I have a problem in my project with the .designer which as everyone know
hi there everyone i have a question on joomla, i have made a site
Asking a simple question, just want everyone have fun to solve it. I got
everyone! i have a question about sessions hopefully someone can help me with. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.