aspxgridview动态绑定数据 获取选中行的值
protected void GridViewDataBind()//绑定数据
{
DataSet ds = new DataSet();
StringBuilder sb = new StringBuilder();
sb.Append("select * from Eric_AA");
ds = conn.dataSetQuery(sb.ToString());
this.ASPxGridView1.DataSource = ds.Tables[0].DefaultView;
this.ASPxGridView1.KeyFieldName = "ID";
this.ASPxGridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e) //获取选中行的主键的值
{
List<object> values = ASPxGridView1.GetSelectedFieldValues(new string[] { ASPxGridView1.KeyFieldName });
for (int i = 0; i < values.Count; i++)
{
this.TextBox1.Text += values[i].ToString() + ",";
}
}
为什么获取不到选中行的值?