运行时的 AspxGridView 选择

发布于 2024-11-04 22:35:35 字数 1248 浏览 0 评论 0原文

我的页面上有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热情消退 2024-11-11 22:35:35

您似乎没有指定行选择操作所需的 ASPxGridView.KeyFieldName 属性:

gv_Attributes.KeyFieldName = "ColorCode";
//gv_Attributes.KeyFieldName = Unique Key Field;

It seems that you do not specify the ASPxGridView.KeyFieldName property that is required for Row Selection operation:

gv_Attributes.KeyFieldName = "ColorCode";
//gv_Attributes.KeyFieldName = Unique Key Field;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文