我有一个ASPxGridView,它填充了一些交易。
<dx:ASPxGridView ID="grdCapTrans" runat="server" ClientIDMode="AutoID" Width="100%" EnableRowsCache="false">
</dx:ASPxGridView>
当它填充时,我想让用户自由选择一行并查看所点击行的详细信息。细节应显示在文本框中的gridview下面。
如何触发并在服务器上处理?
答案 0 :(得分:0)
您可以使用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
答案 1 :(得分:0)
<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";
}
message元素是一个div,可以在updatepanel1中找到。如果selectionChanged事件触发,我期待显示消息“Happy”。令我惊讶的是,事实并非如此。
什么是错的,怎么能纠正。