Click here to Skip to main content
15,922,407 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Create TreeView Type GridView[^]

In the above referenced code, I have added a template field to the gridview
TemplateField tfield = new TemplateField();
                    tfield.HeaderText = "abc";
                    GridView1.Columns.Add(tfield);


How can I put values in it. I want to put two values in the template field.

column name

2.3 july
0.4 aug
4.5 sep

the two values will come from different columns of the database.

How can I do it dynamically using c#?

Please answer in relation to the above referenced code.


Please consider the case of a postback on pressing a button. Adding 2 literal controls to TemplateField may fail to display the data after postback.

If it can be done with Itemplate, then what controls should I add?

If possible explain with few lines of code.
Posted
Comments
Emad Al Hawary 3-Feb-14 8:05am    
CHECK THIS

http://msdn.microsoft.com/en-us/library/bb288032.aspx

1 solution

Check this tutorial. I think it will help you

http://msdn.microsoft.com/en-us/library/bb288032.aspx[^]

This tutorial, we will use TemplateFields to customize the appearance of a list of employees. Specifically, we'll list all of the employees, but will display the employee's first and last names in one column, their hire date in a Calendar control, and a status column that indicates how many days they've been employed at the company.
 
Share this answer
 

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