Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

Keep gridview in edit mode when update fails due to data conflict - Part 20

Автор: kudvenkat

Загружено: 2013-03-10

Просмотров: 30188

Описание:

Link for csharp, asp.net, ado.net, dotnet basics and sql server video tutorial playlists
   / kudvenkat  

Link for text version of this video
http://csharp-video-tutorials.blogspo...

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
   / @aarvikitchen5572  

In this video, we will discuss about
1. Diplaying appropriate status messages depending on the success of update.
2. If the update fails, leave the row in "Edit" mode.

Please watch Part 19 of asp.net gridview tutorial before proceeding.

If there are no concurrency conflicts and if the update succeeds, then we want to display successful status message.

On the other hand if there are data conflicts, and if the update fails, then we want to display failure status message. At the same time, we also want to retain the row in EDIT mode.

There are 3 steps to achieve this.
Step 1: In EmployeeDataAccessLayer class, change the return type of UpdateEmployee() method from "void" to "int"
public static int UpdateEmployee(int original_EmployeeId, string original_Name, string original_Gender, string original_City, string Name, string Gender,

string City)

ExecuteNonQuery() method of the command object, returns an integer indicating the number of rows updated. We want our UpdateEmployee() method to

return this value.
So, instead of "cmd.ExecuteNonQuery()" use "return cmd.ExecuteNonQuery()"

Step 2: Use "Updated" event handler of "ObjectDataSource1" control. This event is fired after the "Update" operation has completed, that is, after the execution of UpdateEmployee() method. Remember UpdateEmployee() method returns an integer back. Notice that we are checking if the "ReturnValue" is an integer. If it is an integer and greater than zero, then we are using the "RetunValue"(the value that is returned by UpdateEmployee() method) to initialize "AffectedRows" property. This "AffectedRows" property will be used in "GridView1_RowUpdated" event handler.

Step 3: Use "RowUpdated" event handler of "GridView1" control. Notice that we are using "AffectedRows" property to determine, if the update has succeeded or not. Remember this is the property that we initialized in Step 2.

To make things clear
1. First UpdateEmployee() method gets executed, and this method returns an integer value indicating the number of rows updated.
2. Then "Updated" event of "ObjectDataSource1" control is invoked. In this event handler method, we retrieve the value returned by "UpdateEmployee()"

and then use it to initialize "AffectedRows" property.
3. Finally "RowUpdated" event of "GridView1" control is invoked. In this event handler method, we use "AffectedRows" property to determine, if the update

has succeeded or not.

Make sure to include a "Label" control on your webform with ID=lblMessage.

Keep gridview in edit mode when update fails due to data conflict - Part 20

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

GridView TemplateField in asp.net - Part 21

GridView TemplateField in asp.net - Part 21

Displaying images in asp.net gridview using imagefield - Part 31

Displaying images in asp.net gridview using imagefield - Part 31

GridView insert update delete in asp.net - Part 23

GridView insert update delete in asp.net - Part 23

Чистая архитектура с ASP.NET Core 10

Чистая архитектура с ASP.NET Core 10

Using validation controls with asp.net gridview when editing data - Part 22

Using validation controls with asp.net gridview when editing data - Part 22

Что происходит в Чечне и что это говорит о будущем России (English subtitles)

Что происходит в Чечне и что это говорит о будущем России (English subtitles)

ФСБ против Кадыровых. Заблокированы миллионы карт. Авария на ЖД, десятки жертв | Жуковский | ВОЗДУХ

ФСБ против Кадыровых. Заблокированы миллионы карт. Авария на ЖД, десятки жертв | Жуковский | ВОЗДУХ

Где начало СХЕМЫ? Понимаем, читаем, изучаем схемы. Понятное объяснение!

Где начало СХЕМЫ? Понимаем, читаем, изучаем схемы. Понятное объяснение!

ООП На Простых Примерах | Объектно-Ориентированное Программирование

ООП На Простых Примерах | Объектно-Ориентированное Программирование

Kubernetes — Простым Языком на Понятном Примере

Kubernetes — Простым Языком на Понятном Примере

Путин перестал говорить о войне | Что случилось (English subtitles)

Путин перестал говорить о войне | Что случилось (English subtitles)

The Windows 11 Disaster Microsoft Didn’t See Coming

The Windows 11 Disaster Microsoft Didn’t See Coming

Repeater control in asp.net - Part 60

Repeater control in asp.net - Part 60

КАТАСТРОФА С БЮДЖЕТОМ/ РЕЗКИЙ РОСТ ЦЕН/ БИЗНЕС В ПАНИКЕ/ ИСТЕРИКА ДЕРИПАСКИ. Милов об экономике

КАТАСТРОФА С БЮДЖЕТОМ/ РЕЗКИЙ РОСТ ЦЕН/ БИЗНЕС В ПАНИКЕ/ ИСТЕРИКА ДЕРИПАСКИ. Милов об экономике

Datagrid in asp net   Part 1

Datagrid in asp net Part 1

Sorting an asp.net gridview in ascending and descending order - Part 48

Sorting an asp.net gridview in ascending and descending order - Part 48

Вся база SQL для начинающих за 1 час

Вся база SQL для начинающих за 1 час

asp.net detailsview insert update delete using sqldatasource control - Part 40

asp.net detailsview insert update delete using sqldatasource control - Part 40

Наследный беспредел. Как из-за ДТП с младшим Кадыровым почти сорвался план Рамзана | Срочный Разбор

Наследный беспредел. Как из-за ДТП с младшим Кадыровым почти сорвался план Рамзана | Срочный Разбор

Formatting gridview using rowdatabound event   Part 8

Formatting gridview using rowdatabound event Part 8

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com