【问题标题】:Get column name dynamically in AspxGridview在 AspxGridview 中动态获取列名
【发布时间】:2020-03-13 22:13:40
【问题描述】:

我在 Web 应用程序中使用带有 contrxtmenustrip 的 Aspxgridview。 在 aspxgridview 中有 5 列包含一些行数据。右键单击网格后,我需要知道用户单击了哪一行以及列名是什么,而无需在代码级别手动传递列索引。

int rowVisibleIndex = int.Parse(hf["VisibleIndex"].ToString());

通过这样做,我可以获得行号。以同样的方式,我需要用户在客户端选择的列名。

【问题讨论】:

    标签: c# asp.net devexpress


    【解决方案1】:
    gridView.Rows['Index of selected row']['Index or column name of cell you want to get value` from']
    

    具体来说:

    gridView.Rows[gridView.SelectedRowIndex]["ID"]
    

    UPDATE 和列 Header 使用这个:

    private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
    {
        string headerText = dataGridView1.Columns[e.ColumnIndex].HeaderText;
    }
    

    【讨论】:

    • 感谢您的快速回复。但是我在运行时需要用户从 aspxgridview 中选择的列名。
    • 单击单元格时,我们需要选定单元格列的标题。在 devexpress aspxgridview 控件中找不到上述事件。
    • 我正在寻找 ASPXGridview (devexpress) 控件的答案,而不是 Microsoft 网格控件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-22
    相关资源
    最近更新 更多