Click here to Skip to main content
16,018,294 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Dim ds As DataSet = ocon.FillSPDataSet(myproc, param)

            Dim col As New DataColumn
            col.ColumnName = "SrNo"
            col.Caption = "Srno"
            ds.Tables(0).Columns.Add(col)
            For i = 0 To ds.Tables(0).Rows.Count - 1
                ds.Tables(0).Rows(i)("SrNo") = 1 + 1

            Next
            If Not ds.Tables(0).Rows.Count = 0 Then
                GridView1.DataSource = ds
                GridView1.DataBind()
            End If


<asp:gridview id="GridView1" runat="server" cellpadding="2" forecolor="#333333" gridlines="None"
="" autogeneratecolumns="False" autogeneratedeletebutton="false" horizontalalign="Center" cssclass="border">
<footerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White">
<columns>
<asp:templatefield headertext=" Sr.No" sortexpression=" ID" visible="False">
<itemtemplate>
<asp:label id="lblid" runat="server" text="<%# Eval("SrNo") %>">



<asp:templatefield headertext="Registration Number" sortexpression="Inst_Name">
<itemtemplate>
<asp:label id="lblInstName" runat="server" text="<%# Eval("Registration_Number") %>">



<asp:templatefield headertext="Roll No" sortexpression="ADMISSION YEAR">
<itemtemplate>
<asp:label id="lblAyear" runat="server" text="<%# Eval("RollNo") %>">



<asp:templatefield headertext="Name" sortexpression="COURSE">
<itemtemplate>
<asp:label id="lblcourse" runat="server" text="<%# Eval("Candidate_1stName") %>">



<asp:templatefield headertext="Father Name" sortexpression="BRANCH">
<itemtemplate>
<asp:label id="lblbranch" runat="server" text="<%# Eval("Father_Name") %>">



<asp:templatefield headertext="DateofBirth" sortexpression="NAME">
<itemtemplate>
<asp:label id="lblname" runat="server" text="<%# Eval("DateofBirth") %>">



<asp:templatefield headertext="Diploma %" sortexpression="SEX">
<itemtemplate>
<asp:label id="lblSex" runat="server" text="<%# Eval("Acadamic_Diploma_Percentage") %>">




<rowstyle backcolor="#F7F6F3" forecolor="#333333">
<editrowstyle backcolor="#999999">
<selectedrowstyle backcolor="#E2DED6" font-bold="True" forecolor="#333333">
<pagerstyle backcolor="#284775" forecolor="White" horizontalalign="Center">
<headerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White">
<alternatingrowstyle backcolor="White" forecolor="#284775">
Posted

VB
Dim ds As New DataSet
        Dim adp As New SqlDataAdapter("Select * from admusermaster", con)
        adp.Fill(ds)
        Dim col As New DataColumn
        col.ColumnName = "SerialNumber"
        ds.Tables(0).Columns.Add(col)
        'ds.Tables(0).Columns.
        For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
            ds.Tables(0).Rows(i)("SerialNumber") = i + 1
        Next
        ds.Tables(0).Columns("SerialNumber").SetOrdinal(0)
        GridView1.DataSource = ds.Tables(0)
        GridView1.DataBind()
 
Share this answer
 
VB
ds.Tables(0).Rows(i)("SrNo") = i + 1


This should do the trick.
 
Share this answer
 
This is what you are looking for. Simple, easy and lightweight . Just use this code and you will get it done just like that........ and it will work in paging also...
<pre>
<asp:TemplateField>
<HeaderTemplate>
Serial No.</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblSRNO" runat="server"
Text='<%#Container.DataItemIndex+1 %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
</pre>
you can ask me any questions i will try my hand on that....

tell me after you done....

happy coding
<code>adsfadsf</code>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900