运行时的 AspxGridView 选择
我的页面上有一个 aspxGridView
,我在运行时创建列。我还添加了 CommandColumn
,并将 ShowSelectCheckBox
设置为 true。但是在我选择一行并单击按钮获取行值后,AspxGridView.Selection.Count
返回0
。我在 AspxButtons Click 事件上创建这个 GridView
也用于分页,在 Page_Init
上创建 gridView。这是创建 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 have an aspxGridView
on my page, and i create the columns at runtime. I also add CommandColumn
with ShowSelectCheckBox
set to true. But after i select one row and click a button to get the row values, AspxGridView.Selection.Count
returns 0
. I create this GridView
on AspxButtons Click event also for paging, create the gridView on Page_Init
. Here is the code to create the 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎没有指定行选择操作所需的 ASPxGridView.KeyFieldName 属性:
It seems that you do not specify the ASPxGridView.KeyFieldName property that is required for Row Selection operation: