Generate sequence number in grid view10yAsked Nov 21, 2016, 12:22 AM EST5 answersShareLinkedInXCopy linkSave Hello friends, how to generate sequence number in grid view?
Generate sequence number in grid view10yAsked Nov 21, 2016, 12:22 AM EST5 answersShareLinkedInXCopy linkSave Hello friends, how to generate sequence number in grid view?
Suvendu Shekhar GiriRank #546 · 4.4K reputation10y agoPosted Nov 21, 2016, 12:33 AM EST+3VB.NETCopy"SL"> "lblSlNo" runat="server" Text=''> "Center" Width="30px" /> "Center" Width="30px" />Please refer my blogpost for details-https://suvendugiri.wordpress.com/2011/11/26/auto-generate-serial-no-for-gridview/ Hope, it helps :)+3
Salman BegRank #284 · 8.8K reputation10y agoPosted Nov 21, 2016, 12:30 AM EST+1Hi.You can generate sequence number by using 1. Using DataItemIndex.2. Using RowDataBound event.please follow this article,http://www.aspsnippets.com/Articles/Add-Show-Serial-Number-in-First-Column-of-GridView-in-ASPNet-using-C-and-VBNet.aspxthanks. +1MPMilan Prajapati107 reputation10y agoPosted Nov 22, 2016, 12:01 AM EST0 With the help of DataItemIndex , you can generate sequence number. Below is the example: <asp:TemplateField HeaderText="No."> <ItemTemplate> <%# Container.DataItemIndex + 1 %> ItemTemplate> asp:TemplateField> 0Rajeesh MenothRank #118 · 18.4K reputation10y agoPosted Nov 22, 2016, 12:18 AM EST0Hi, Inside the ItemTemplate you can add the following code..It will create a auto generated id.<%# Container.DataItemIndex + 1 %> Reference : http://www.c-sharpcorner.com/code/1763/creating-auto-generated-column-id-in-gridview.aspx 0Amit GuptaRank #190 · 12.8K reputation10y agoPosted Nov 22, 2016, 1:19 AM EST0Hey Subhalaxmi,Well I had implemented this in ADO.NET by following the easy steps:1. Create a column name (like # or SlNo) in your dataTable ( that you used to bind in gridview).2. Create a thread that will loop from 0 to DataTable.Rows.Count3. Set the row value from the loop likeDataTable.Rows [x]["#"]=(x+1) Thats it.Hope it helps0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
MPMilan Prajapati107 reputation10y agoPosted Nov 22, 2016, 12:01 AM EST0 With the help of DataItemIndex , you can generate sequence number. Below is the example: <asp:TemplateField HeaderText="No."> <ItemTemplate> <%# Container.DataItemIndex + 1 %> ItemTemplate> asp:TemplateField> 0
Rajeesh MenothRank #118 · 18.4K reputation10y agoPosted Nov 22, 2016, 12:18 AM EST0Hi, Inside the ItemTemplate you can add the following code..It will create a auto generated id.<%# Container.DataItemIndex + 1 %> Reference : http://www.c-sharpcorner.com/code/1763/creating-auto-generated-column-id-in-gridview.aspx 0
Amit GuptaRank #190 · 12.8K reputation10y agoPosted Nov 22, 2016, 1:19 AM EST0Hey Subhalaxmi,Well I had implemented this in ADO.NET by following the easy steps:1. Create a column name (like # or SlNo) in your dataTable ( that you used to bind in gridview).2. Create a thread that will loop from 0 to DataTable.Rows.Count3. Set the row value from the loop likeDataTable.Rows [x]["#"]=(x+1) Thats it.Hope it helps0
Suvendu Shekhar GiriRank #546 · 4.4K reputationPosted Nov 21, 2016, 12:33 AM EST
"SL"> "lblSlNo" runat="server" Text=''> "Center" Width="30px" /> "Center" Width="30px" />Salman BegRank #284 · 8.8K reputationPosted Nov 21, 2016, 12:30 AM EST
1. Using DataItemIndex.
2. Using RowDataBound event.
Milan Prajapati107 reputationPosted Nov 22, 2016, 12:01 AM EST
Rajeesh MenothRank #118 · 18.4K reputationPosted Nov 22, 2016, 12:18 AM EST
Amit GuptaRank #190 · 12.8K reputationPosted Nov 22, 2016, 1:19 AM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts