0% found this document useful (0 votes)
115 views2 pages

Editing and Updating Data in Gridview Using Sqldatasource Control - Part 17

This document discusses editing and updating data in a GridView control using a SqlDataSource control in ASP.NET. It describes configuring the SqlDataSource to generate INSERT, UPDATE, and DELETE statements and associating it with the GridView. The document explains that clicking Edit displays Update and Cancel buttons and allows editing field values. It notes that the EmployeeID primary key is read-only and that empty strings are converted to NULL by default.

Uploaded by

shradha11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views2 pages

Editing and Updating Data in Gridview Using Sqldatasource Control - Part 17

This document discusses editing and updating data in a GridView control using a SqlDataSource control in ASP.NET. It describes configuring the SqlDataSource to generate INSERT, UPDATE, and DELETE statements and associating it with the GridView. The document explains that clicking Edit displays Update and Cancel buttons and allows editing field values. It notes that the EmployeeID primary key is read-only and that empty strings are converted to NULL by default.

Uploaded by

shradha11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

8/28/2017 Sql server, .

Sql server, .net and c# video tutorial: Editing and updating data in gridview using sqldatasource control - Part 17

More Next Blog Create Blog Sign In

Sql server, .net and c# video tutorial


Free C#, .Net and Sql server video tutorial for beginners and intermediate programmers.

Support us .Net Basics C# SQL ASP.NET ADO.NET MVC Slides C# Programs Subscribe Buy DVD

Editing and updating data in gridview using sqldatasource control - Part


17

Suggested Videos
Part 14 - ConflictDetection property of SqlDataSource control
Part 15 - Deleting data from gridview using objectdatasource control Best software training and placements in
Part 16 - ConflictDetection property of objectdatasource control marathahalli, bangalore. For further
details please call 09945699393.

CBSE Class 9 Maths


In this video we will discuss about editing and updating data in gridview control using
Number Systems
sqldatasource control

We will be using tblEmployee table for this demo. SQL script to create and populate CPT Tutorial
this table with sample data is available in Part 13 of asp.net gridview tutorial. Part 1 : Video | Text | Slides

Create an asp.net web application. Drag and drop a sqldatasource control and a
Important Videos
gridview control on webform1.aspx.
The Gift of Education

Web application for your business

Configure "SqlDataSource1" control How to become .NET developer


1. Right click on "SqlDataSource1" control and select "Show Smart Tag"
2. Now click on "Configure Data Source" link Resources available to help you
3. Select connection string, from the dropdownlist on "Choose your data connection"
screen. You need to have a connection string specified in web.config file.
Dot Net Video Tutorials
4. Click Next
Angular 2 Tutorial
5. On "Configure the Select Statement" screen, select "tblEmployee" table from
dropdownlist. Design Patterns
6. Click on "Advanced" button
7. Select "Generate INSERT, UPDATE and DELETE statements" checkbox and click ASP.NET Web API
OK
8. Click Next and Finish Bootstrap

Now flip "WebForm1.aspx" to "HTML Source" mode. Notice that, the wizard has AngularJS Tutorial
automatically generated INSERT, UPDATE and DELETE statements. Since, we only
jQuery Tutorial
want to enable the gridview control to eidt and update data, get rid of InsertCommand,
InsertParameters, DeleteCommand, and DeleteParameters. JavaScript with ASP.NET Tutorial

Now let us associate "SqlDataSource1" control with "GridView1" control JavaScript Tutorial
1. Right click on "GridView1" control and select "Show Smart Tag"
2. Select "SqlDataSource1" from "Choose Data Source" dropdownlist Charts Tutorial
3. Select "Enable Editing" checkbox. At this point "Edit" button should appear on the
gridview control. LINQ

LINQ to SQL
Now run the application. Click "Edit" button. Notice that "Update" and "Cancel"
buttons are displayed, when the row is in EDIT mode. Also, notice that except LINQ to XML
"EmployeeId", all the other columns display a TextBox control, so the user can change
data. By default, bound fields display a textbox control as the editing interface. It makes Entity Framework
more sense to display a dropdownlist control as the editing interface, for "Gender" and
http://csharp-video-tutorials.blogspot.in/2013/03/editing-and-updating-data-in-gridview.html 1/3
8/28/2017 Sql server, .net and c# video tutorial: Editing and updating data in gridview using sqldatasource control - Part 17
"City". We will discuss about doing this in a later video session. WCF

EmployeeId column is the primary key, and it is unusal to change key column values. ASP.NET Web Services
Notice the HTML of the gridview control. The bound column that displays "EmployeeId"
Dot Net Basics
is marked with ReadOnly="True". This is the reason EmployeeId is not editable, when
the row is in EDIT mode. C#

1. Click "Edit" button in a row SQL Server


2. Delete the value in "Name" column
3. Click "Update" ADO.NET
4. Check the data for this column in the database.
ASP.NET
Notice that NULL is stored. This is because, "BoundField" and "UpdateParameters" has
GridView
a property "ConvertEmptyStringToNull". This property is true by default. If you want
to store an "EmptyString" instead of NULL, set this property to false. ASP.NET MVC

This property need to be set at both places. Visual Studio Tips and Tricks
1. On the BoundField and
2. On the respective update parameter Dot Net Interview Questions

Slides
Entity Framework

WCF

ASP.NET Web Services

Dot Net Basics

C#

SQL Server

ADO.NET

ASP.NET

GridView
1 comment:
ASP.NET MVC

Job January 28, 2014 at 4:06 AM Visual Studio Tips and Tricks
hello sir
I am getting this type of error. Java Video Tutorials
Part 1 : Video | Text | Slides
Incorrect syntax near 'nvarchar'.
Must declare the scalar variable "@ID".
Part 2 : Video | Text | Slides
how to solve this
Part 3 : Video | Text | Slides
Reply

Interview Questions
C#
Enter your comment...
SQL Server

Written Test
Comment as: Select profile...

Publish Preview

http://csharp-video-tutorials.blogspot.in/2013/03/editing-and-updating-data-in-gridview.html 2/3

You might also like