GridView is built to work with DataSource. This DataSource can be either dataset or a DataSource control.
When using GV with DSet, you have to handle the Paging, Editing, Sorting functions.
When using GV with DSrc, the above functions are built-in for you. If you have a strict 3-tier architecture, use ObjectDataSource control.
Suppose I don’t use a primary key column in the SELECT statement for SqlDataSource. What would happen in that case?
I tried it and in the UPDATE command i set the condition to check for a specific primary key value but the catch is there is no PK in SELECT statement. When I tried to run this code, I didn’t get any error. I was able to click ‘EDIT’ button of GridView, enter new information and UPDATE it. However the thing is no info was updated. It didn’t show any error but it didnt give the desired result either.
So have one column as PK. If you didn’t select any PK column, at least set the DataKeys value to a column name. This way the column will be made a PK column for the datatable.