我有一个ASPxGridView,它填充了一些事务。
<dx:ASPxGridView ID="grdCapTrans" runat="server" ClientIDMode="AutoID" Width="100%" EnableRowsCache="false"> </dx:ASPxGridView>
当它被填充时,我想给予用户选择一行并查看所点击行的详细信息的自由。详细信息将显示在网格视图下方的文本框中。如何在服务器上触发和处理此操作?
tsm1rwdh1#
您可以使用RowCommand eventLink:http://documentation.devexpress.com/#AspNet/DevExpressWebASPxGridViewASPxGridView_RowCommandtopic
RowCommand event
<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();
Link: http://documentation.devexpress.com/#AspNet/DevExpressWebASPxGridViewASPxGridView_RowDeletingtopic
bkkx9g8r2#
<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中找到。我希望在selectionChanged事件触发时显示消息“Happy”。令我惊讶的是,它没有。什么是错误的,如何才能纠正。
2条答案
按热度按时间tsm1rwdh1#
您可以使用
RowCommand event
Link:http://documentation.devexpress.com/#AspNet/DevExpressWebASPxGridViewASPxGridView_RowCommandtopic
代码隐藏:
绑定您的数据
Link: http://documentation.devexpress.com/#AspNet/DevExpressWebASPxGridViewASPxGridView_RowDeletingtopic
bkkx9g8r2#
代码隐藏
消息元素是一个div,可以在updatepanel1中找到。我希望在selectionChanged事件触发时显示消息“Happy”。令我惊讶的是,它没有。
什么是错误的,如何才能纠正。