How to add a Template. Field to a Grid. View dynamically? Grid. View is a very powerful and highly customizable control provided by ASP. NET. The process of adding a Grid. View control dynamically to a page is almost same as of the other controls. But the problem comes when you want to add a Template. Field dynamically to a dynamically created Grid. View control. This is so because the Template. Field has few child templates which are not very easy to create dynamically. CGridView displays a list of data items in terms of a table. Each row of the table represents the data of a single data item, and a column usually represents an. Take the tedium out of building complex GUIs in ASP.NET by creating nested GridView controls. An article on how to use GridView control available in ASP.Net 2.0 having multiple controls in template inside it. To achieve this I have found a way which is described below. Step 1: – Create a Class which should be inherited from the ITemplate interface.– Put this class in the same namespace of your project.– This class should contain a parameterrised constructor. This constructor should take a List. Item. Type object as its parameter.– Overwrite the function Instantiate. In() of the ITemplate interface, which takes an container object as its argument.– In the code check for if the List. Item. Type object is an Item object or not. Forum thread about Header Background Color in UI for Silverlight. Join the conversation now. The only tricky part is the little bit of plumbing that actually hooks the template class up to the GridView. This is accomplished by creating a new TemplateField. If yes then create an object of the control which you want to put in the Teamplate. Field, set its property and add it to the container object. Eg–public class Create. Item. Template : ITemplate. If you need then you can create other types of templates. For that you have to check for the List. Item. Type for any specific Item and add specific controls accordingly. Then during the creation of the object of the class you have to pass the respective List. Item. Type as an parameter to the class constructor as described in the below example. Eg- Changes need in the class –public void Instantiate. In(System. Web. UI. Control container). Replacing / Adding Line Breaks in Grid. View Text - Always Get Better. The Grid. View is a powerful control for quickly and easily displaying tables of data.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2016
Categories |