DataGrid Web Control 基本操作
来源:互联网 发布:40万的suv 知乎2017 编辑:程序博客网 时间:2024/05/22 21:17
自动分页:AllowPaging= TRUE!!!!
private void dgCategory_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
dgCategory.CurrentPageIndex=e.NewPageIndex;
dgCategory.DataBind();
}
排序:默认按“PKId”排序
private void dgCategory_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
string SortOrder=e.SortExpression.ToString();
BindData(SortOrder);
}
private void BindData(string SortOrder)
{
ProductSystem productSys=new ProductSystem();//底层数据接口
CategoryData categorySet=productSys.GetCategories(1); //底层数据接口,返回ID为1的Category
DataView categoryView=categorySet.Tables[CategoryData.CATEGORIES_TABLE].DefaultView;
categoryView.Sort=SortOrder;
lblTitle.Text="按"+SortOrder+"排序";
dgCategory.DataSource=categoryView;
dgCategory.DataBind();
}
private void Page_Load(object sender, System.EventArgs e)
{
BindData("PKId");
}
编辑,更新,取消:
private void dgCategory_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
dgCategory.EditItemIndex=e.Item.ItemIndex;
BindData("PKId");
}
private void dgCategory_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
dgCategory.EditItemIndex=-1;
BindData("PKId");
}
private void dgCategory_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string strUpdate="";
strUpdate+="PKId='"+((TextBox)e.Item.Cells[1].Controls[0]).Text+"'";
strUpdate+="ParentId='"+((TextBox)e.Item.Cells[2].Controls[0]).Text+"'";
strUpdate+="Description='"+((TextBox)e.Item.Cells[3].Controls[0]).Text+"'";
strUpdate+="IsLeaf='"+((TextBox)e.Item.Cells[4].Controls[0]).Text+"'";
try
{
CagegorySet.ExecuteUpdate(strUpdate);//需要后台提供更新的接口
dgCategory.EditItemIndex=-1;
}
catch
{
Response.Write("<script language='javascript'>alert('未能完成更新,请…………')</script>");
}
BindData("PKId");
}
private void dgCategory_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//获得关键字,使用DataKeys集合访问数据列表控件中每个记录的键值(显示为一行)
//使得用户可以存储键字段而无需在控件中显示它
string PKId=dgCategory.DataKeys[e.Item.ItemIndex];
CategorySet.ExecuteDelete(PKId);
}*/
- DataGrid Web Control 基本操作
- List Control 最基本操作
- DataGrid Control, EditText Control
- Web中的基本操作
- Playing with DataGrid Control
- Extending the DataGrid Control
- WPF DataGrid Control
- DataGrid control for WPF
- 关于List Control控件实现翻页操作的基本代码
- Using DropDownList control in DataGrid
- Using DropDownList control in DataGrid
- DataGrid的使用:(一)、在DataGrid控件中实现基本的操作(编辑、删除、分页)
- DataGrid的使用:(一)在DataGrid控件中实现基本的操作(编辑、删除、分页)
- ubuntu基本操作和web环境搭建
- ASP.NET Web API 基本操作(CRUD)
- ASP.NET Web API 基本操作(CRUD)
- ASP.NET Web API 基本操作(CRUD)
- List Control 基本使用
- PlugIn
- [收集]c#.net函数和方法集
- 在 C# 中实现 Singleton
- 使代码简洁的五条忠告--Delphi园地
- 让fopen打开在不同的代码页下创建的文件
- DataGrid Web Control 基本操作
- 优化.NET异常处理
- How to Bind an ArrayList to a DataGrid
- j2me实现图像旋转
- UNIX下实现终端打印的几种方法
- 在C#中用最简洁有效的代码执行存储过程并返回数据
- C#执行存储过程的简化 选择自 spanzhang 的 Blog
- ASP中如何执行存储过程? 选择自 leonduan 的 Blog
- March Library中的Multiboolean——多值逻辑实现