1.取得控件值
using System.Collections.Generic;
//取得当前控件值的集合 直接寻找控件的ID
List<object> keyValues = this.GridViewmethod.GetSelectedFieldValues("F_XXX");//控件的ID
foreach (object key in keyValues)//循环遍历出来
{
}
2.在AspGridView取得某一行
List<object> keyValues = this.GridViewmethod.GetCurrentPageRowValues("F_xxxxx");//F_xxxxx是主键的值
foreach (object key in keyValues)//循环遍历这一行的每一列的数据
{
}
3获得某行某列的值
this.ASPxGridView1.GetRowValues(e.VisibleIndex, new string[] {"列的名字"});
---------------------------------------------------------我是分割线--------------------------------------------------------------------------
1、获取所有选择行中的数据
protected void btnDel_Click(object sender, EventArgs e)
{
//遍历所有可见行
for (int i = 0; i < ASPxGridView1.VisibleRowCount; i++)
{
DataRowView dv;
if (ASPxGridView1.Selection.IsRowSelected(i))
{
//行数据集
dv = (DataRowView)ASPxGridView1.GetRow(i);
//获取选择行的第n列数据
string ordno =dv.Row[0].ToString();
Response.Write("<script>alert('"+ordno+"');</script>");
}
}
}
2、遍历主键列中的所有数据
List<object> keyValue = AspxGridView1.GetSelectedFieldValues("kid");
string str;
foreach(object key in keyValue)
{
str = key.ToString();
}
3、全选/反选
<dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Width="50px">
<HeaderTemplate>
<input type="checkbox" οnclick="ASPxGridView1.SelectAllRowsOnPage(this.checked);" />全选
</HeaderTemplate>
</dxwgv:GridViewCommandColumn>
常用方法:
获取单元格的值 decimal change = (decimal)grid.GetRowValues(e.VisibleIndex, "Change");
获取模板中的控件 Label label = grid.FindRowCellTemplateControl(e.VisibleIndex, null, "changePercent") as Label;