Total Page Preview:   000000001463

What is Template field control in ASP.NET in English and Hindi

Template field in ASP.NET in Engilsh 

TemplateField control in ASP.NET is a powerful data-bound control that allows developers to customize the rendering and behavior of data in a GridView control. It allows developers to define a template that will be used to display or edit data, which can include static text, HTML elements, or even other ASP.NET controls.

Here's a detailed example of how to use the TemplateField control in ASP.NET:
Let's say we have a database table called "Employees" that stores information about employees, including their ID, name, position, and salary. We want to display this information in a GridView control, along with a button to edit the employee's information and a button to delete the employee.
 
First, we create a GridView control and define the columns that we want to display:
 
In the TemplateField controls, we define the "ItemTemplate" that will be used to display data for each row. In this example, we include a button control in each TemplateField that will be used to edit or delete the employee's information. We also use the "Eval" method to bind the "CommandArgument" property of the button to the "ID" field of the data source.
 
Next, we need to handle the "Edit" and "Delete" button click events in our code-behind file:
In this example, we handle the "RowCommand" event of the GridView control. When the "Edit" or "Delete" button is clicked, we extract the employee ID from the "CommandArgument" property and perform the appropriate action. For the "Edit" button, we might redirect the user to a page where they can edit the employee's information. For the "Delete" button, we might delete the employee from the database.
By using the TemplateField control, we can easily customize the rendering and behavior of our data-bound controls in ASP.NET.
 
 

Template field in ASP.NET in Hindi

TemplateField control ASP.NET me ek data-bound control hai jo developers ko GridView control me data ka rendering aur behavior customize karne ki anumati deta hai. Isme developers template ko define kar sakte hain jise data ko display ya edit karne ke liye use kiya jata hai, jisme static text, HTML elements, ya phir dusre ASP.NET controls bhi shamil ho sakte hain.
 
Yahan ek detailed example hai ki kaise ASP.NET me TemplateField control ka upyog karte hain:
Man lijiye hamare pas ek database table hai jise "Employees" kaha jata hai aur jisme karmachariyon ke bare me jankari hai, jisme unke ID, naam, position aur vetan shamil hai. Ham chahte hain ki is jankari ko ek GridView control me display kiya jaye, sath hi sath karmachari ke jankari ko edit karne ke liye ek button aur use delete karne ke liye ek button shamil karna chahte hain.
 
Sabse pahle, ham ek GridView control create karenge aur usme wo column define karenge jo hame display karne hain:
TemplateField controls me, ham "ItemTemplate" ko define karte hain jo har row ke liye data ko display karne ke liye use kiya jayega. Is example me, ham har TemplateField me ek button control shamil karte hain jise karmachari ke jankari ko edit ya delete karne ke liye use kiya jata hai. Ham "CommandArgument" property ko "ID" field ke data source se bind karne ke liye "Eval" method ka upyog karte hain.
 
Ab, hame "Edit" aur "Delete" button click events ko code-behind file me handle karna hoga:
Is example me, ham GridView control ke "RowCommand" event ko handle karte hain. Jab "Edit" ya "Delete" button click kiya jata
 
 
 
 
 
 
 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: