View rowupdating

For this sample to work, you must install the Sql Server 2008 R2 Express.This sample contains a Sql Server database file, if you do not install Sql Server, The Data In page can also works fine.In this tutorial I will show you how you can create an editable Grid View control for administrators to modify database records directly into the Grid View control.Editing the Grid View control can be an incredibly easy feature to add for certain database tables, especially those who have no foreign key associated and can easily be edited through the use of a standard Text Box web control as shown in the figure below: 1.A Grid View Update Event Args object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the update operation should be canceled.

The sample demonstrates data source from both database and memory.By Default, Grid View control displays Item Template which directly shows the Product Name and Unit Price columns but when user clicks Edit button Grid View automatically switches to Edit Item Template and display the control available inside Edit Item Template for user editing.Now I will show you the C# code behind file of the above ASP.If we move our mouse on to the variables, which hold the cell values, we can see the old value instead of new updated value (Refer the debugging Screen Shot at the Top). protected void gv Contact Info_Row Editing(object sender, Grid View Edit Event Args e) protected void gv Contact Info_Row Updating(object sender, Grid View Update Event Args e) protected void gv Contact Info_Row Canceling Edit(object sender, Grid View Cancel Edit Event Args e) Label lbl = ((Label)gv Contact Info. Set a debugger at the beginning of the event fired, walk through it step by step, and see if the value is updating at the spot where you're expecting.

Leave a Reply