我正在尝试使用带有按钮的GetSelectedFieldValues方法从ASPxGridView中的所选行中获取一个值这么简单。
我已经按照DevExpress文档中的步骤进行了操作,我想要检索Label中的值。使用经典的ASPGridView没什么困难。
Protected Sub ASPxButton1_Click(sender As Object, e As EventArgs) Handles ASPxButton1.Click
Dim oRowVal As List(Of Object)
Dim oVal As Object
oRowVal = ASPxGridView1.GetSelectedFieldValues({"No_"})
oVal = oRowVal(0)
Label1.Text = oVal.ToString
End Sub
正如您所看到的,我想要的是在ASPxGridView中获取所选值并将其显示在Label中。
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<dx:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="False" Text="ASPxButton" Theme="BlackGlass" Width="150px">
</dx:ASPxButton>
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" EnableTheming="True" Theme="BlackGlass">
<Columns>
<dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
<ClearFilterButton Visible="True">
</ClearFilterButton>
</dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn Caption="GP" FieldName="No_" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Description" FieldName="Descripción Grupo" VisibleIndex="2">
</dx:GridViewDataTextColumn>
</Columns>
<SettingsBehavior AllowSelectSingleRowOnly="True" />
<Settings ShowFilterRow="True" ShowGroupPanel="True" />
</dx:ASPxGridView>
提前致谢!!!
答案 0 :(得分:0)
指定 ASPxGridView.KeyFieldName 属性以使用选择状态:
<dx:ASPxGridView ... KeyFieldName="...">
顺便提一下,以下代码是否会返回正确的结果?
oRowVal = ASPxGridView1.GetSelectedFieldValues({"No_"})
oVal = oRowVal(0)