Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть ConflictDetection property of objectdatasource control - Part 16

  • kudvenkat
  • 2013-03-06
  • 19028
ConflictDetection property of objectdatasource control - Part 16
ConflictDetectionobjectdatasourceconcurrencyCompareAllValuesOverwriteChangesgridviewdeleting datadelete data
  • ok logo

Скачать ConflictDetection property of objectdatasource control - Part 16 бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно ConflictDetection property of objectdatasource control - Part 16 или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

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

Cкачать музыку ConflictDetection property of objectdatasource control - Part 16 бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео ConflictDetection property of objectdatasource control - Part 16

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 Part 15 of the asp.net gridview tutorial we discussed about deleting data from gridview control using objectdatasource control. We did not discuss about concurrency in Part 15. Let me explain what I mean.
1. When you access the webform, data is loaded into gridview control.
2. While you are looking at this data in the gridview control, someone else has updated a row in the database table
3. Now, in the gridview, when you click the delete button on the row that has changed, the row gets deleted.

This may be fine in most cases. However, let's say we don't want to allow the row to be deleted, in case if it has changed, then, we can make use of ConflictDetection property of the objectdatasource control.

We will be modifying the "DeleteEmployee()" method in EmployeeDataAccessLayer.cs file. We discussed about this in Part 15. Please change the implementation of DeleteEmployee() method as shown below. Notice that the ORIGINAL EmployeeId, Name, Gender and City are now passed as parameters to the DeleteEmployee() method. These parameters are then used in the "DELETE" query, to check if the data has changed after it was loaded into the gridview control.
public static void DeleteEmployee(int original_EmployeeId, string original_Name,
string original_Gender, string original_City)
{
string CS = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
string deleteQuery = "DELETE FROM tblEmployee WHERE EmployeeId = @original_EmployeeId " +
"AND Name = @original_Name AND Gender = @original_Gender AND City = @original_City";
SqlCommand cmd = new SqlCommand(deleteQuery, con);
SqlParameter paramEmployeeId = new SqlParameter("@original_EmployeeId", original_EmployeeId);
cmd.Parameters.Add(paramEmployeeId);
SqlParameter paramName = new SqlParameter("@original_Name", original_Name);
cmd.Parameters.Add(paramName);
SqlParameter paramGender = new SqlParameter("@original_Gender", original_Gender);
cmd.Parameters.Add(paramGender);
SqlParameter paramCity = new SqlParameter("@original_City", original_City);
cmd.Parameters.Add(paramCity);
con.Open();
cmd.ExecuteNonQuery();
}
}

Compile the project and re-configure ObjectDataSource1 control, to use the above method as it's DELETE method.

Finally on "ObjectDataSource1" control, set properties
ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="original_{0}"

Setting ConflictDetection="CompareAllValues", will pass original values for EmployeeId, Name, Gender and City to DeleteEmployee() method.

Notice the parameters of the DeleteEmployee() method. All of them have a prefix of "original_". ObjectDataSource control uses "OldValuesParameterFormatString" property to figure out the exact name of the parameters for the original values. This is the reason we have set OldValuesParameterFormatString="original_{0}"
public static void DeleteEmployee(int original_EmployeeId, string original_Name, string original_Gender, string original_City)

Комментарии

Информация по комментариям в разработке

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

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

Контакты для правообладателей [email protected]