后台帮定代码:using System;
using System.Collections.Generic;
using System.Linq;using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Datagrid();
}
private void Datagrid()
{ DataTable data = DB.FillDataTable_Pro("select top 40 * from bi_t_item_info"); this.ASPxGridView1.DataSource = data;
this.ASPxGridView1.DataBind();
}
//***事件
protected void ASPxGridView1_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
DB.ExecuteScalar(string.Format("delete bi_t_item_info where item_no='{0}'", str)); e.Cancel = true;
Datagrid();
}
}
前台代码:
OnDataBound="ASPxGridView1_DataBound"
KeyFieldName="item_no"
>
ReadOnly="true">
ReadOnly="true">
ReadOnly="true">
ReadOnly="false">
VisibleIndex="4" ReadOnly="false">
VisibleIndex="4" ReadOnly="false">
要注意的是,有红色标示地方,此处必须是主键,我就是因为这个地方没有邦定主键,***事件不执行,查了好久才查出来!
对于ASPxGridView***按钮的确认弹出框,只需要简单设置几个属性即可。
1.首先自然要先启用行的***功能。
2.然后设置ASPxGridView的SettingsBehavior的ConfirmDelete属性为Ture,即启用***功能的确认框。
3.设置弹出框内容文本。在ASPxGridView的SettingsText中设置ConfirmDelete属性为”确定要***吗?”即可。
几个常用属性IsEditing :是否处于编辑状态IsNewRowEditing :是否是新建行的编辑状态
GridLines="Vertical" :网格样式Vertical, Both, None
ShowGroupPanel="True" :分组面板ShowFooter="True" :脚注面板ShowFilterRow="True" :过滤器行ShowHeaderFilterButton="true" :表头过滤按钮ShowGroupFooter="VisibleAlways" :分组脚注面板Hidden | VisibleIfExpand | VisibleAlways
ShowPreview="true" :预览面板ShowVerticalScrollBar="True" :垂直滚动条VerticalScrollableHeight="250" :垂直滚动条SettingsBehaviorAllowDragDrop="False" :允许托拽ColumnResizeMode="Control" :列宽度调整模式AllowFocusedRow="True" :鼠标点击选择行PageSize="30" :分页大小Mode="ShowAllRecords" :展示模式SEOFriendly="Enabled" : Search engine friendly
Position="TopAndBottom" :分页控件位置SettingsText
Title="标题"
EmptyDataRow="无数据"
PopupEditFormCaption="编辑"ConfirmDelete="确定***?"
编辑模式SettingsEditing.Mode
EditForm :当前行转化为表单,嵌入在行中EditFormAndDisplayRow :同EditForm,但保留当前行Inline :在当前行现场编辑PopupEditForm :弹出窗口编辑
几个常用方法获取单元格的值decimal change = (decimal)grid.GetRowValues(e.VisibleIndex, "Change");获取模板中的控件Label label = grid.FindRowCellTemplateControl(e.VisibleIndex, null, "changePercent") as Label;