GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Microsoft  >  DataGrid

 Print  |  
Question:  Data grid Serial Number

Answer: How to add Serial Number in the data grid dynamically, Windows application, using C#


March 03, 2009 02:03:08 #2
 nt57323   Member Since: March 2009    Total Comments: 3 

RE: Data grid Serial Number
 
I am providing the solution in ASP. Just convert this as you like.
I have tried
this one at my end and its working fine.
Just take one Template field as
Serialno. in Datagrid.
Below is the code in HTML:

< size=2>asp: size=2>TemplateField HeaderText color=#0000ff size=2>="Sl.no" size=2>HeaderStyle-ForeColor size=2>="White">

<
size=2>ItemTemplate>

<
size=2>asp: size=2>Label ID size=2>="lblslno" size=2>runat="server" color=#ff0000 size=2>Text=' size=2><%# Slcount() %> size=2>'></asp size=2>:Label size=2>>

</
size=2>ItemTemplate>

</
asp color=#0000ff size=2>: size=2>TemplateField>


Slcount() is the function which i have taken in the code page.

Take one variable Count as integer.

In the above function take Count= Count + 1. Initially count will be taken as
Zero.

Below is the code in the code page:


Dim
count
as
integer
= 0

Public Function
Slcount()
as
Integer

    count
=
count
+
1

   
Return
count

End Function


Enjoy Coding.


     

 

Back To Question