C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to add a counter column to a DataGrid?


Posted Date: 13 Jun 2007      Total Responses: 1

Posted By: Kalyani       Member Level: Gold     Points: 2


How to add a counter column to a DataGrid?



Responses

Author: ChandraShekarThota    18 Jun 2007Member Level: DiamondRating:     Points: 2
<asp:Datagrid id="Datagrid1" runat="server">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Label id="Label1" Runat ="server" > <%#getCount%> </asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:Datagrid>




Code behind
VB.NET


Dim count As Integer
protected function getCount() As Integer
count = count + 1
Return count
End Function


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Populate the Datagrid populating data from the database
'.....
End Sub




C#


int count =0;
protected int getCount()
{
count = count + 1;
return count;
}


private void Page_Load(object sender, System.EventArgs e)
{
//Populate the Datagrid populating data from the database
//....
}


Post Reply
You must Sign In to post a response.
Next : How to set a different color for every alternate row of a datagrid?
Previous : How to change the HeaderText of the Datagrid?
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing service

Contact Us    Privacy Policy    Terms Of Use