• http://www.techneurons.com/career/
  • experienced programming consultants for hire !!!

    Contact Now

    ASP.NET Support

    How to add serial number field in a gridview?

    Posted by Maq on Apr 17, 2010
    I need to display serial numbers in the leftmost column of a gridview. Could you please suggest me how to get this done?
    Replied by consultsarath on Apr 17, 2010
    <p>You can add a serial number field to your GridView by having a TemplateField with ItemTemplate containing the <strong>Container.DisplayIndex</strong>. This property is zero-indexed, you would need to add the value by 1. A simple example would be like this.</p> <div style="line-height: normal"><span style="font-family: 'Courier New'; color: blue; font-size: 9pt">&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 9pt">asp</span><span style="font-family: 'Courier New'; color: blue; font-size: 9pt">:</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 9pt">TemplateField</span><span style="font-family: 'Courier New'; color: blue; font-size: 9pt">&gt;</span></div> <div style="line-height: normal"><span style="font-family: 'Courier New'; font-size: 9pt">&nbsp;&nbsp;&nbsp; <span style="color: blue">&lt;</span><span style="color: #a31515">ItemStyle</span> <span style="color: red">Width</span><span style="color: blue">=&quot;30px&quot;</span> <span style="color: blue">/&gt;</span></span></div> <div style="line-height: normal"><span style="font-family: 'Courier New'; font-size: 9pt">&nbsp;&nbsp;&nbsp; <span style="color: blue">&lt;</span><span style="color: #a31515">ItemTemplate</span><span style="color: blue">&gt;</span></span></div> <div style="line-height: normal"><span style="font-family: 'Courier New'; font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="background: yellow">&lt;%</span><span style="color: blue">#</span> Container.DataItemIndex + 1 <span style="background: yellow">%&gt;</span><span style="color: red"><font color="#000000">.</font>&amp;nbsp;</span></span></div> <div style="line-height: normal"><span style="font-family: 'Courier New'; font-size: 9pt">&nbsp;&nbsp;&nbsp; <span style="color: blue">&lt;/</span><span style="color: #a31515">ItemTemplate</span><span style="color: blue">&gt;</span></span></div> <div style="margin: 0cm 0cm 10pt"><span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 9pt">&lt;/</span><span style="line-height: 115%; font-family: 'Courier New'; color: #a31515; font-size: 9pt">asp</span><span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 9pt">:</span><span style="line-height: 115%; font-family: 'Courier New'; color: #a31515; font-size: 9pt">TemplateField</span><span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 9pt">&gt;</span></div> <p>&nbsp;</p>
    We are experts in Cloud Computing Technologies. We can assist you to build high scalable business applications using Amazon Web Services (Amazon EC2, Amazon S3, Amazon SES, SNS, CloudFront), Windows Azure Platforms - Windows Azure and SQL Server Azure, Google App Engine using Python and Django Framework. We are Expert Programming Consultants available at affordable rates per hour. We work on several technologies - .NET, Python, Google App Engine, PHP, Windows Azure, Amazon Web Services ...