This article explains how to perform insert, update and delete operations in ASP. Let us take an example to perform CRUD operations using Entity Framework Database First approach.Suppose we’ve to work on Customer table having Category ID as foreign key.Data Key Names was not my problem; I had it set correctly.The WHERE clause of my SELECT query referenced a control parameter against a Text Box on my form.In this article, I am going to take a simple database table that has following fields: Auto ID - Int, Auto Increment, Primary Key Page Name - Varchar(50) Page Description - Varchar(500) Active - Bit(1) In this article, I am not going to explain the workings of Sql objects but focusing on the events and methods of the Grid View that will help us in updating and deleting the records.Now let’s start with putting the Grid View on page. Data Key Names="Auto ID" Auto Generate Edit Button="True" On Row Editing="Edit Record" On Row Canceling Edit="Cancel Record" On Row Updating="Update Record" Cell Padding="4" Header Style-Horizontal Align="left" On Row Deleting="Delete Record" Row Style-Vertical Align="Top" Fore Color="#333333" Grid Lines="None" In the above code, I have kept Auto Generate Columns as false so that Grid View will not render all the fields of the data source automatically.I had inadvertently set Enable View State for this textbox to "False".Because of this, the Grid View was rebinding itself before the UPDATE occurred.
I tend to use business objects in my applications so using the standard data controls doesn't work very well, nor would it really buy much in terms of abstraction.
"If you like my work; you can appreciate by leaving your comments, hitting Facebook like button, following on Google , Twitter, Linked in and Pinterest, stumbling my posts on stumble upon and subscribing for receiving free updates directly to your inbox .
Free counters Added on January 19,2012 Follow Me @vmsdurano A bit About Me Disclaimer The opinions expressed herein are my own personal opinions and does not represent the opinions of my employers. Contol)Text; it werk just Fine any comment and thx for the code Instead of adding a Customer ID to your table and later pulling the text to get the ID number, a more reliable way to do it is to add a Data Key Names field to the grid example in the page: You can then access this information at any time with the following in code: Grid View1. Row Index]["id"]); You can do this with any field, but I've found customers get confused when they see the ID field and kept asking me why it was there, this also eliminates any issues if you change the display order of your table later (maybe add an edit/update/cancel control) Hey...great article ;)But I got a problem... So here I go with my example:protected void Grid View1_Row Updating(object sender, Grid View Update Event Args e) and the debugger says: Exception Details: System.
I have specified Data Key Names as Auto ID, the primary key of the database table.
Then I have several methods attached with following events Get video of hundreds of ASP. On Row Editing - Edit Record On Row Cancel Edit - Cancel Record On Row Updating - Update Record On Row Deleting - Delete Record As I set Auto Generate Columns property to false so I am going to manually write the fields name that I need to appear in the way I want.