Dev不同的版本可能操作不同:
相似的官方文章:https://www.devexpress.com/Support/Center/Example/Details/E529/
相关操作:http://codecentral.devexpress.com/E529/
该文章很好使用了details的使用方法,可以借鉴。
本人在不使用datasource空间的时候使用该方法。方法如下:
前台代码:
<dx:ASPxGridView ID="ASPxGridView1" runat="server" Width="100%" AutoGenerateColumns="False" ClientIDMode="AutoID" KeyFieldName="pk_notice" ClientInstanceName="grid" OnRowDeleting="grid_RowDeleting" > <SettingsDetail ShowDetailRow="True" /> <SettingsBehavior AllowDragDrop="False" AllowSort="False" AllowFocusedRow="True" AllowSelectByRowClick="True" AllowSelectSingleRowOnly="True" ConfirmDelete="True"></SettingsBehavior> <SettingsText EmptyDataRow="无相关记录!" ConfirmDelete="确定删除吗?"></SettingsText> <SettingsDetail ShowDetailRow="True"></SettingsDetail> <Templates> <DetailRow> <table style=" width :100%" > <tr ><td style="text-align:center; background-color:#FFF9EE ; font-weight : bold;"> 通知 </td> </tr> <tr ><td> <dx:ASPxLabel ID="ASPxLabel1" runat="server" OnInit ="ASPxLabel1_Init"> </dx:ASPxLabel> </td> </tr> </table> </DetailRow> </Templates> <Columns> <dx:GridViewCommandColumn VisibleIndex="0"> <DeleteButton Text="删除" Visible="True"> </DeleteButton> <ClearFilterButton Visible="True"> </ClearFilterButton> </dx:GridViewCommandColumn> <dx:GridViewDataTextColumn Caption="pk_notice" FieldName="pk_notice" Visible="False" VisibleIndex="1"></dx:GridViewDataTextColumn> <dx:GridViewDataTextColumn Caption="标题" FieldName="cTitle" VisibleIndex="2"> </dx:GridViewDataTextColumn> <dx:GridViewDataTextColumn Caption="发布人" FieldName="cWriter" VisibleIndex="3"> </dx:GridViewDataTextColumn> <dx:GridViewDataTextColumn Caption="发布时间" FieldName="dNewDate" VisibleIndex="4"> </dx:GridViewDataTextColumn> </Columns> <SettingsBehavior AllowDragDrop="False" AllowFocusedRow="True" AllowSort="False" ConfirmDelete="True" AllowSelectSingleRowOnly="True" AllowSelectByRowClick="True" /> <SettingsText EmptyDataRow="无相关记录!" ConfirmDelete="确定删除吗?" /> </dx:ASPxGridView>
后台代码:
protected void ASPxLabel1_Init(object sender, EventArgs e) { ASPxLabel fv = (ASPxLabel)sender; GridViewDetailRowTemplateContainer row = (GridViewDetailRowTemplateContainer)fv.Parent; string txt = "select cDetails from EI_Notice where pk_notice =‘" + row.KeyValue.ToString() + "‘"; DataTable dt = CreateData1(txt); fv.Text=dt.Rows [0][0].ToString (); }
有相似问题的可以留言。
detailrow中可以插入其他的可用的控件,当然包括表格。相似的例子可在官方网中进行查找。
时间: 2024-10-12 21:53:57