0

I have 1 data gridview. in that first is ID column . for that i assign a auto index number with sql server (isidentiyt). the next colomn is response id, for this column also i want autonumber id like 1,2,3,4..... . i see we cant assign to index identity with sql server for one table. can we generate tis id for gridview column with code.?
please help!

3
Contributors
2
Replies
5
Views
8 Years
Discussion Span
Last Post by srikanthkadem
0

I have 1 data gridview. in that first is ID column . for that i assign a auto index number with sql server (isidentiyt). the next colomn is response id, for this column also i want autonumber id like 1,2,3,4..... . i see we cant assign to index identity with sql server for one table. can we generate tis id for gridview column with code.?
please help!

Add a column at runtime

TemplateField col=new TemplateField();
        col.HeaderText="Response ID";
        GridView1.Columns.Add(col);
        //bind the data
        int count = GridView1.Rows.Count;
        for (int i = 0; i < count; i++) {
            GridView1.Rows[i].Cells[0].Text = (i + 1).ToString();
        }
0
<asp:TemplateField>
    <ItemTemplate>
        <%# Container.DataItemIndex + 1 %>
    </ItemTemplate>
</asp:TemplateField>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.