| Author: ChandraShekarThota 18 Jun 2007 | Member Level: Diamond | Rating: 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 //.... }
|