﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - WebGRID Column Show  Row Number </title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGRID-Column-Show-Row-Number/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>WebGRID Column Show  Row Number </title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGRID-Column-Show-Row-Number/</link><pubDate>Thu, 13 Aug 2015 06:21:26 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="color: #1f497d;"&gt;I haven't tested following solution further, but you can give it a try. It adds an AutoIncrement column to the DataTable.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: #1f497d;"&gt;Snippet code of &lt;strong&gt;OnInitializeDataSource&lt;/strong&gt; event handler:&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;protected void WebGrid1_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
{
    OleDbCommand selectCommand = new OleDbCommand();
    selectCommand.Connection = con;
    selectCommand.CommandText = "SELECT * FROM Customers";

    OleDbDataAdapter da = new OleDbDataAdapter();
    da.SelectCommand = selectCommand;

    DataTable dt = new DataTable();

    dt.Columns.Add("RowNumber", typeof(int));
    dt.Columns[0].AutoIncrement = true;
    dt.Columns[0].AutoIncrementSeed = 1;
    dt.Columns[0].AutoIncrementStep = 1;

    da.Fill(dt);
    e.DataSource = dt;
}&lt;/pre&gt;&lt;br&gt;
&lt;p&gt;&lt;span style="color: #1f497d;"&gt;WebGrid's column definition:&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;&amp;lt;ISWebGrid:WebGrid ID="WebGrid1" runat="server" Height="250px" UseDefaultStyle="True"
    Width="500px" RenderingMode="HTML5"
    OnInitializeDataSource="WebGrid1_InitializeDataSource"&amp;gt;
    &amp;lt;RootTable DataKeyField="CustomerID"&amp;gt;
        &amp;lt;Columns&amp;gt;
            &amp;lt;ISWebGrid:WebGridColumn Caption="Row Number" DataMember="RowNumber"
                Name="Row Number" Width="100px"&amp;gt;
            &amp;lt;/ISWebGrid:WebGridColumn&amp;gt;
            &amp;lt;ISWebGrid:WebGridColumn Caption="CustomerID" DataMember="CustomerID"
                Name="CustomerID" Width="100px"&amp;gt;
            &amp;lt;/ISWebGrid:WebGridColumn&amp;gt;
            &amp;lt;ISWebGrid:WebGridColumn Caption="CompanyName" DataMember="CompanyName"
                Name="CompanyName" Width="100px"&amp;gt;
            &amp;lt;/ISWebGrid:WebGridColumn&amp;gt;
            &amp;lt;ISWebGrid:WebGridColumn Caption="ContactName" DataMember="ContactName"
                Name="ContactName" Width="100px"&amp;gt;
            &amp;lt;/ISWebGrid:WebGridColumn&amp;gt;
            ...
        &amp;lt;/Columns&amp;gt;
    &amp;lt;/RootTable&amp;gt;
&amp;lt;/ISWebGrid:WebGrid&amp;gt;&lt;/pre&gt;&lt;br&gt;
&lt;p&gt;&lt;span style="color: #1f497d;"&gt;The result is:&lt;/span&gt;&lt;/p&gt;
&lt;img src="http://www.intersoftpt.com/Community/Attachments/24523/WebGridRowNumberColumn.png" style="height:300px;width:400px;"&gt;</description></item><item><title>WebGRID Column Show  Row Number </title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGRID-Column-Show-Row-Number/</link><pubDate>Wed, 12 Aug 2015 03:42:37 GMT</pubDate><dc:creator>17964281@qq.com</dc:creator><description>Please Look attachment ;&amp;nbsp;&lt;div&gt;looks like attachment column ;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;a column , data is &amp;nbsp;per rows number ;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;</description></item></channel></rss>