最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
使用 ASP+ DataGrid 控件来创建主视图/详细资料视图 (2)
时间:2022-06-30 10:41:33 编辑:袖梨 来源:一聚教程网
Step6Page.cs:
namespace Samples {
...
public class Step6Page : Page {
// 更新当前选定的作者并重新加载与选定内容对应的书名
// 网格
protected void LoadTitlesGrid() {
UpdateSelection();
titlesGrid.DataBind();
}
// 处理书名网格中的 CancelCommand 事件,以
// 不施用更改就结束编辑
protected void OnCancelCommandTitlesGrid(object sender,
DataGridCommandEventArgs e) {
titlesGrid.EditItemIndex = -1;
LoadTitlesGrid();
}
// 处理书名网格中的 EditCommand 事件,以
// 开始编辑某一行
protected void OnEditCommandTitlesGrid(object sender,
DataGridCommandEventArgs e) {
titlesGrid.EditItemIndex = e.Item.ItemIndex;
LoadTitlesGrid();
}
// 处理书名网格中的 UpdateCommand 事件,以施用
// 所作的更改并结束编辑
protected void OnUpdateCommandTitlesGrid(object sender,
DataGridCommandEventArgs e) {
TextBox priceText =
(TextBox)e.Item.FindControl("Column3Control");
string newPrice = priceText.Text.Substring(1);
DataSet ds = GetSessionData();
DataTable titlesTable = ds.Tables["Title"];
string titleID =
(string)titlesGrid.DataKeys[e.Item.ItemIndex];
DataRow[] rows = titlesTable.Select("title_id = '" +
titleID + "'");
DataRow editRow = rows[0];
editRow.BeginEdit();
editRow["price"] = newPrice;
editRow.EndEdit();
editRow.AcceptChanges();
namespace Samples {
...
public class Step6Page : Page {
// 更新当前选定的作者并重新加载与选定内容对应的书名
// 网格
protected void LoadTitlesGrid() {
UpdateSelection();
titlesGrid.DataBind();
}
// 处理书名网格中的 CancelCommand 事件,以
// 不施用更改就结束编辑
protected void OnCancelCommandTitlesGrid(object sender,
DataGridCommandEventArgs e) {
titlesGrid.EditItemIndex = -1;
LoadTitlesGrid();
}
// 处理书名网格中的 EditCommand 事件,以
// 开始编辑某一行
protected void OnEditCommandTitlesGrid(object sender,
DataGridCommandEventArgs e) {
titlesGrid.EditItemIndex = e.Item.ItemIndex;
LoadTitlesGrid();
}
// 处理书名网格中的 UpdateCommand 事件,以施用
// 所作的更改并结束编辑
protected void OnUpdateCommandTitlesGrid(object sender,
DataGridCommandEventArgs e) {
TextBox priceText =
(TextBox)e.Item.FindControl("Column3Control");
string newPrice = priceText.Text.Substring(1);
DataSet ds = GetSessionData();
DataTable titlesTable = ds.Tables["Title"];
string titleID =
(string)titlesGrid.DataKeys[e.Item.ItemIndex];
DataRow[] rows = titlesTable.Select("title_id = '" +
titleID + "'");
DataRow editRow = rows[0];
editRow.BeginEdit();
editRow["price"] = newPrice;
editRow.EndEdit();
editRow.AcceptChanges();
相关文章
- 美国运通美联储更新引发瑞波整合热议 07-02
- 火影忍者晓迪达拉怎么玩 07-02
- 火影忍者六道枫怎么玩 07-02
- 像素纪元弓箭手电套CD流玩法分享 07-02
- 地下城与勇士起源2024金秋套外观全职业怎么样 地下城与勇士起源全职业金秋套外观详情 07-02
- PS把白天风景图片制作成夜晚星光朦胧效果教程 07-02