我有一个 ASPxGridView,它填充一些事务。
<dx:ASPxGridView ID="grdCapTrans" runat="server" ClientIDMode="AutoID" Width="100%" EnableRowsCache="false">
</dx:ASPxGridView>
填充后,我想让用户自由选择行并查看单击行的详细信息。详细信息应显示在网格视图下方的文本框中。
如何在服务器上触发和处理?
您可以使用
RowCommand event
链接:http://documentation.devexpress.com/#AspNet/DevExpressWebASPxGridViewASPxGridView_RowCommandtopic
<dx:ASPxGridView ID="grid"
runat="server"
ClientInstanceName="grid"
AutoGenerateColumns="false"
onrowcommand="grid_RowCommand" >
<Columns>
<dx:GridViewCommandColumn ShowSelectCheckbox="true" VisibleIndex="0" ButtonType="Button" />
</Columns>
</dx:ASPxGridView>
背后代码:
protected void grid_RowCommand(object sender, ASPxGridViewRowCommandEventArgs e)
{
.....
}
绑定您的数据
grid.DataSource = ...;
grid.DataBind();
链接:http://documentation.devexpress.com/#AspNet/DevExpressWebASPxGridViewASPxGridView_RowDeletingtopic
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" >
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cboTransType" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<dx:ASPxGridView ID="grdCapTrans" runat="server" ClientIDMode="AutoID" Width="100%" EnableRowsCache="false" ClientInstanceName="grdCapTrans" onselectionchanged="grdCapTrans_SelectionChanged"
EnableCallBacks="false" KeyFieldName="ID" AutoGenerateColumns="false">
<Columns>
<dx:GridViewCommandColumn ShowInCustomizationForm="True" VisibleIndex="0" ButtonType="Button" ShowSelectCheckbox="true"> </dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn FieldName="ID" Name="ID" ShowInCustomizationForm="True" VisibleIndex="1"></dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Description" Name="Description" ShowInCustomizationForm="True" VisibleIndex="2"></dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Amount" Name="Amount" ShowInCustomizationForm="True" VisibleIndex="5"></dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Date" Name="Date" ShowInCustomizationForm="True" VisibleIndex="4"></dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Capturer" Name="Capturer" ShowInCustomizationForm="True" VisibleIndex="3"></dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Status" Name="Status" ShowInCustomizationForm="True" VisibleIndex="6"></dx:GridViewDataTextColumn>
</Columns>
<SettingsBehavior ProcessSelectionChangedOnServer="true" AllowFocusedRow="true" AllowSelectByRowClick="true" EnableRowHotTrack="true" />
</dx:ASPxGridView>
<p>
</p>
</ContentTemplate>
</asp:UpdatePanel>
背后代码
protected void grdCapTrans_SelectionChanged(object sender, EventArgs e)
{
UpdatePanel1.Update();
txtFullName.Text = grdCapTrans.GetSelectedFieldValues("Description")[1].ToString();
message.InnerHtml = "Happy";
}
消息元素是一个 div,位于 updatepanel1 中。我希望在选择更改事件触发时显示消息“快乐”。令我惊讶的是,事实并非如此。
出了什么问题以及如何纠正。