[英]AspxGridView selection at runtime
I have an aspxGridView
on my page, and i create the columns at runtime.我的页面上有一个
aspxGridView
,我在运行时创建了列。 I also add CommandColumn
with ShowSelectCheckBox
set to true.我还添加了将
ShowSelectCheckBox
设置为 true 的CommandColumn
。 But after i select one row and click a button to get the row values, AspxGridView.Selection.Count
returns 0
.但是在我 select 一行并单击按钮以获取行值之后,
AspxGridView.Selection.Count
返回0
。 I create this GridView
on AspxButtons Click event also for paging, create the gridView on Page_Init
.我在 AspxButtons Click 事件上创建此
GridView
也用于分页,在Page_Init
上创建 gridView 。 Here is the code to create the AspxGridView
:这是创建
AspxGridView
的代码:
Colenter code hereorCollection colorCol = ConfAttributesManager.Instance
.GetColors();
if (colorCol.Count > 0)
{
GridViewDataTextColumn grdColorCodeColumn = new GridViewDataTextColumn();
grdColorCodeColumn.FieldName = "ColorCode";
GridViewDataTextColumn grdDescriptionColumn = new GridViewDataTextColumn();
grdDescriptionColumn.FieldName = "Description";
gv_Attributes.Columns.Clear();
gv_Attributes.Columns.Add(grdColorCodeColumn);
gv_Attributes.Columns.Add(grdDescriptionColumn);
GridViewCommandColumn grdCmdColumn = new GridViewCommandColumn();
grdCmdColumn.ShowSelectCheckbox = true;
grdCmdColumn.VisibleIndex = 0;
gv_Attributes.Columns.Add(grdCmdColumn);
gv_Attributes.DataSource = colorCol;
gv_Attributes.DataBind();
}
I don't know where do i make a mistake?我不知道我在哪里犯了错误?
Thanks for your help.谢谢你的帮助。
It seems that you do not specify the ASPxGridView.KeyFieldName property that is required for Row Selection operation:您似乎没有指定行选择操作所需的 ASPxGridView.KeyFieldName 属性:
gv_Attributes.KeyFieldName = "ColorCode";
//gv_Attributes.KeyFieldName = Unique Key Field;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.