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

Скачать или смотреть GridView insert update delete without using datasource controls - Part 25

  • kudvenkat
  • 2013-03-14
  • 124422
GridView insert update delete without using datasource controls - Part 25
  • ok logo

Скачать GridView insert update delete without using datasource controls - Part 25 бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно GridView insert update delete without using datasource controls - Part 25 или посмотреть видео с ютуба в максимальном доступном качестве.

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

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

Cкачать музыку GridView insert update delete without using datasource controls - Part 25 бесплатно в формате MP3:

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

Описание к видео GridView insert update delete without using datasource controls - Part 25

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  

We discussed about inserting, updating and deleting data from gridview, using sqldatasource control in Part 23. In Part 24, we discussed about achievieng the same, using ObjectDataSource control. It is also possible to perform insert, update and delete on gridview, without using datasource controls at all, and that's what we will discuss in this video. Please watch Part 23 and Part 24, before proceeding with this video. We will be modifying the example, that we used in Part 24.

1. As we don't want to use datasource controls. Please delete "ObjectDataSource1" control from the webform.

2. Delete DataSourceID="ObjectDataSource1" from GridView1. This should remove the dependency of GridVIew1 on ObjectDataSource1 control.

3. From the code behind file, delete lbInsert_Click() event handler method.

4. In the "FooterTemplate" of "EmployeeId" TemplateField, please delete OnClick="lbInsert_Click", as we no longer have this event handler method.

5. Delete "CommandField" column from GridView1

6. Now, include a template field in the place of CommandField. This template field is used to display Edit, Update, Cancel and Delete link buttons. We don't want delete and cancel buttons to cause validation, so set CausesValidaion property of these buttons to false.

7. Copy and paste the following private method. This method binds employee data with gridview1 control.
private void BindGridViewData()
{
GridView1.DataSource = EmployeeDataAccessLayer.GetAllEmployees();
GridView1.DataBind();
}

8. Call BindGridViewData() in Page_Load() event.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridViewData();
}
}

7. Finally generate GridView1_RowCommand() event handler method. Copy and Paste the following code.
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "EditRow")
{
int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
GridView1.EditIndex = rowIndex;
BindGridViewData();
}
else if (e.CommandName == "DeleteRow")
{
EmployeeDataAccessLayer.DeleteEmployee(Convert.ToInt32(e.CommandArgument));
BindGridViewData();
}
else if (e.CommandName == "CancelUpdate")
{
GridView1.EditIndex = -1;
BindGridViewData();
}
else if (e.CommandName == "UpdateRow")
{
int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;

int employeeId = Convert.ToInt32(e.CommandArgument);
string name = ((TextBox)GridView1.Rows[rowIndex].FindControl("TextBox1")).Text;
string gender = ((DropDownList)GridView1.Rows[rowIndex].FindControl("DropDownList1")).SelectedValue;
string city = ((TextBox)GridView1.Rows[rowIndex].FindControl("TextBox3")).Text;

EmployeeDataAccessLayer.UpdateEmployee(employeeId, name, gender, city);

GridView1.EditIndex = -1;
BindGridViewData();
}
else if (e.CommandName == "InsertRow")
{
string name = ((TextBox)GridView1.FooterRow.FindControl("txtName")).Text;
string gender = ((DropDownList)GridView1.FooterRow.FindControl("ddlGender")).SelectedValue;
string city = ((TextBox)GridView1.FooterRow.FindControl("txtCity")).Text;

EmployeeDataAccessLayer.InsertEmployee(name, gender, city);

BindGridViewData();
}
}

8. If you want to show a confirmation dialog box, before a row is deleted, include javascript confirm() function, using "OnClientClick" attribute of LinkButton "lbDelete".

Комментарии

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

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

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

video2dn Copyright © 2023 - 2025

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