.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

using of template in gridview reg

Posted By: Gowthammanju     Posted Date: May 26, 2011    Points:5   Category :ASP.Net
Hi,
i just want to know how to use the template column in the gridview in order to work with it.
i just want to know the step by step way to find solution for these problem.


waiting for ur responces

thanks in advance


regards,
gowtham

Responses
Author: Gowthammanju             
Posted Date: May 26, 2011     Points: 20   
Author: shiv chandra             
Posted Date: June 07, 2011     Points: 20   

Check out this example.

In below code ItemTemplate is used when data is display in normal mode, while EditItemTemplate will be used when record is in Edit mode.

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="EmployeeID" DataSourceID="ObjectDataSource1">
<Columns>
<asp:TemplateField HeaderText="Name" SortExpression="FirstName">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("FirstName") %>'>
</asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("FirstName") %>'>
</asp:Label>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("LastName") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="HireDate" HeaderText="HireDate" SortExpression="HireDate" />
</Columns>
</asp:GridView>


Regards
Shiva
Author: shiv chandra             
Posted Date: June 07, 2011     Points: 20   

Check out this example.

In below code ItemTemplate is used when data is display in normal mode, while EditItemTemplate will be used when record is in Edit mode.

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="EmployeeID" DataSourceID="ObjectDataSource1">
<Columns>
<asp:TemplateField HeaderText="Name" SortExpression="FirstName">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("FirstName") %>'>
</asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("FirstName") %>'>
</asp:Label>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("LastName") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="HireDate" HeaderText="HireDate" SortExpression="HireDate" />
</Columns>
</asp:GridView>


-------
Shiva


Regards
Shiva


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend