Last post Jun 30, 2016 07:48 PM by avt2k7
Jun 30, 2016 05:11 AM|avt2k7|LINK
I got a table without primary key from imported raw data file of the customer information. For example, tblCustomer (Name, phone, address, etc..). I like to build a website page to populate the data into gridview. How do I can add CRUD to
allow the user can insert, update and delete records from gridview.
Any example code to show how to get it done, I really appreciate it. Thanks in advance.
Jun 30, 2016 06:22 AM|Nan Yu|LINK
Without primary key , how would you identify each record ? I would suggest you could add an IDENTITY column in sql table :
You could set it in SSMS :
Then you will find it will be easy to perform CRUD for gridview.
Jun 30, 2016 10:53 AM|vinz|LINK
Adding to what Nan Yu said, by default GridView doesn't allow you to perform insert. But you could still add data to it. Take a look at these examples about adding, editing, updating and deleting rows in GridView:
Jun 30, 2016 07:48 PM|avt2k7|LINK
I know that the table need a primary key in order to identity the record. and set it by using SSMS. I did several CRUD to perform on table with primary key.
Here is my scenario: my table is imported data from Excel file or raw data file. In my website, we upload the Excel file to temp table, then insert new records into SQL Server table if they are not existed in the table and updated the existed record based
on two fields on the table. Therefore, no identical records in the table but can be duplicated fields on rows.
I will add RowId for identify the records as a primary key. Thanks.