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.
There isn’t a way to merge/combine fields. I think you misunderstood the BoundFields/TemplateField. However you can use
Eval()andBind()to show/bind one or more expression into single cell//column..Read MSDN articles:
EDIT:
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
In .aspx page (Markup),
and in code-behind (aspx.cs),