如何在具有访问数据库的网格视图中执行插入,更新,删除操作 [英] how to perform insert,update ,delete operation in a grid view with a access database

查看:98
本文介绍了如何在具有访问数据库的网格视图中执行插入,更新,删除操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了一些东西但是完全感到困惑?您能给一个简单的方法吗..........:confused:每次我执行更新操作时,按下更新按钮后,整个表的数据都消失了...如何选择数据键名称会导致每次数据运行时都选择任何内容,因此我会显示来自三个不同表的数据

i read something but got totally got confused?can u give a simple method..........:confused: every time i perform the update operation an entire table s data vanishes after i press the update button...how am i suposed to select the data key name cause anything i select every time the data goes, i display data from three different tables

推荐答案

protected void GridView1_RowUpdating (对象发送者,GridViewUpdateEventArgs e)
{
TextBox txtName =(TextBox)GridView1.Rows [e.RowIndex] .FindControl("txtName");
DropDownList cmbGender =(DropDownList)GridView1.Rows [e.RowIndex] .FindControl("cmbGender");
TextBox txtCity =(TextBox)GridView1.Rows [e.RowIndex] .FindControl("txtCity");
DropDownList cmbType =(DropDownList)GridView1.Rows [e.RowIndex] .FindControl("cmbType");

customer.Update(GridView1.DataKeys [e.RowIndex] .Values [0] .ToString(),txtName.Text,cmbGender.SelectedValue,txtCity.Text,cmbType.SelectedValue);
GridView1.EditIndex = -1;
FillCustomerInGrid();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox txtName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName");
DropDownList cmbGender = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbGender");
TextBox txtCity = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtCity");
DropDownList cmbType = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbType");

customer.Update(GridView1.DataKeys[e.RowIndex].Values[0].ToString(),txtName.Text, cmbGender.SelectedValue,txtCity.Text, cmbType.SelectedValue);
GridView1.EditIndex = -1;
FillCustomerInGrid();
}


嘿,它显示了一个错误.....当前背景中不存在填充网格视图,没有更新方法的定义.....感谢您的帮助............我很感激
hey its shows an error........the fill grid view does not exsist in current context n there is no definition for update method.....thanks for ur help............i appreciate it


这篇关于如何在具有访问数据库的网格视图中执行插入,更新,删除操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆