Onrowupdating in gridview in asp net


09-Nov-2015 06:43

If user clicks the Cancel button while Grid View is in editing mode, you need to Cancel the Editing process and also need to reset the Edit Index property to -1 in the Row Canceling Edit event of the Grid View control as shown below: The last step is to handle the Row Updating event to actually update the back end database.

To do this we first need to obtain the reference of the current row by using its index no as shown in the first line below.

NET page that will handle different Grid View events to provide complete editing functionality. Data Bind();} For brevity I am not storing connection string in the web.config and also not using any Data Access Component.

In the Page_Load event, you simply load your data from the database and bind it with the Grid View control as shown below: protected void Page_Load(object sender, Event Args e){ if (! Is Post Back) { Bind Data(); }} private void Bind Data(){ string constr = @"Server=COMPAQ\SQLEXPRESS; Database=Test DB; uid=waqas; pwd=sql;"; string query = "SELECT Product ID, Product Name, Unit Price FROM Products"; Sql Data Adapter da = new Sql Data Adapter(query, constr); Data Table table = new Data Table(); da. Next event is the Grid View Row Editing event to give ASP. You need to set the Edit Index property of the Grid View with the New Edit Index property of the Grid View Edit Event Args class.

These properties will automatically render Edit, Update and Cancel buttons inside Grid View column.

I am using Template Field’s Item Template and Edit Item Template for providing read only and editing interface of the same column in the Grid View.

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.

onrowupdating in gridview in asp net-31

Real free mobile adult cams

onrowupdating in gridview in asp net-17

Free hot chat tv

The visitors to a web site can typically be divided into two groups: the users and the administrators.

In data driven web sites, users are normally allowed to view data and administrators are allowed to add, edit or delete data.



Bass's whirlwind wooing tour was only the latest in a years-long effort to increase options for Humboldt's would-be flyers. Fly Humboldt, the public-private partnership organized to add flight routes into and out of the Arcata-Eureka Airport, has raised more than million to lure airlines to serve the county.… continue reading »


Read more

When you look at this it looks very simple but when we try to think the solution, I have seen developers coming up with many different solutions for example sometime they write cursor, table variables, local variables etc. … continue reading »


Read more

Later developments emulated the different newsgroups or individual lists, providing more than one forum, dedicated to a particular topic.… continue reading »


Read more

Eyeball Chat - Account Setup : - Download Eyeball Chat, the best free video chat software. … continue reading »


Read more

But commuting for hours every day at jobs I didn’t love prevented me from seeing the very people I was doing it for: my family. I began selling tamales door-to-door six days a week, sometimes going to bed around 2AM and waking up at 4AM to continue preparing for the upcoming day.… continue reading »


Read more

But did you know that one in three couples now find love online?… continue reading »


Read more