Gridview Identity Seed Value

Posted on 2006-04-10
Last Modified: 2012-05-05
I have a fairly standard gridview in my application.  The first column is EmpID.  I have added an insert command to my gridview by putting a blank textbox in the <FooterTemplate></FooterTemplate> of each of my columns.  When I perform the import, I want the EmpID to be read only and it to automatically increment to the next possible value in the dB.  It is set as a seed value (increments by 1) already.

Any ideas as to how I would implement this?
Question by:goodmanro
    LVL 5

    Accepted Solution

    If its set to auto increment, shouldn't it auto increment without any code. Just insert all the other values? I'm sorry if I'm not much help.
    LVL 5

    Expert Comment

    Let me ask you one more question. Is this Gridview tied to a dataset? And if so are you inserting the import to the DS or directly to the DB.

    Author Comment

    This gridview is tied to an asp:SqlDataSource.  I tried simply inserting into the dB, but I get a NullExceptionReference for the EmpID field.  Is there somthing that I could do possibly with setting a variable equal to SELECT MAXCOUNT?

    Author Comment

    Is there a way to SET IDENTITY_INSERT ON in a code behind file?  I see how this works in a SP and this could possibly be a solution...

    Author Comment

    This question has been resolved.  Thank you.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now