aspnet-devexpress-dot-web-dot-aspxgridview-dot-getrowvaluesbykeyvalue-x28-system-dot-object-system-dot-string-x29.md
Returns the specified row’s values displayed within the specified columns (fields).
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public object GetRowValuesByKeyValue(
object keyValue,
params string[] fieldNames
)
Public Function GetRowValuesByKeyValue(
keyValue As Object,
ParamArray fieldNames As String()
) As Object
| Name | Type | Description |
|---|---|---|
| keyValue | Object |
An object that uniquely identifies the row.
| | fieldNames | String[] |
The names of data source fields whose values are returned.
|
| Type | Description |
|---|---|
| Object |
An object that contains the row values displayed within the specified columns (fields).
|
The code sample below demonstrates how you can prohibit a user from editing data rows containing information unrelated to the Sales department.
string UserDepartment = "Sales";
...
protected void MyGridView_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e) {
if (MyGridView.GetRowValuesByKeyValue(e.EditingKeyValue, "Department").ToString() != UserDepartment) {
e.Cancel = true;
}
}
Dim UserDepartment As String = "Sales"
...
Protected Sub MyGridView_StartRowEditing(sender As Object, e As DevExpress.Web.Data.ASPxStartRowEditingEventArgs)
If MyGridView.GetRowValuesByKeyValue(e.EditingKeyValue, "Department").ToString() <> UserDepartment Then
e.Cancel = True
End If
End Sub
<dx:ASPxGridView ID="MyGridView" runat="server" AutoGenerateColumns="False" DataSourceID="AccessDataSource1"
KeyFieldName="ID" OnStartRowEditing="MyGridView_StartRowEditing">
<Columns>
<dx:GridViewCommandColumn VisibleIndex="0">
<EditButton Visible="True">
</EditButton>
</dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn FieldName="Department" ReadOnly="True" VisibleIndex="0">
</dx:GridViewDataTextColumn>
...
</Columns>
</dx:ASPxGridView>
The following code snippets (auto-collected from DevExpress Examples) contain references to the GetRowValuesByKeyValue(Object, String[]) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
ASPxGridView grid = (ASPxGridView)sender;
DataType dataType = (DataType)grid.GetRowValuesByKeyValue(e.Keys[0], "Type");
protected void grid_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e) {
object[] vals = (object[])grid.GetRowValuesByKeyValue(e.EditingKeyValue,
new string[] { "Category1ID", "Category2ID", "Category3ID" });
Dim grid As ASPxGridView = DirectCast(sender, ASPxGridView)
Dim dataType As DataType = CType(grid.GetRowValuesByKeyValue(e.Keys(0), "Type"), DataType)
Protected Sub grid_StartRowEditing(ByVal sender As Object, ByVal e As DevExpress.Web.Data.ASPxStartRowEditingEventArgs)
Dim vals() As Object = CType(grid.GetRowValuesByKeyValue(e.EditingKeyValue, New String() { "Category1ID", "Category2ID", "Category3ID" }), Object())
Session("Cat1ID") = vals(0)
See Also