这是我有我的gridview
的地方:
<dx:ASPxGridView ID="GridViewID" runat="server" DataSourceID="SourceMain" ClientInstanceName="Grid" SettingsPager-mode="ShowAllRecords" OnHtmlDataCellPrepared="ASPxGridView1_HtmlDataCellPrepared">
<Columns>
<dx:GridViewDataTextColumn FieldName="TrackOutDate" VisibleIndex="1" Visible="True"><PropertiesTextEdit DisplayFormatString="MM/dd/yyyy"></PropertiesTextEdit></dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="LotID" VisibleIndex="2" Visible="True"></dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Qty_IN" VisibleIndex="11" Visible="True"></dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="HX" VisibleIndex="12" Visible="True"></dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="NA" VisibleIndex="13" Visible="True"></dx:GridViewDataTextColumn>
</Columns>
<Settings ShowFooter="true" />
<TotalSummary>
<dx:ASPxSummaryItem FieldName="Qty_IN" SummaryType="Sum" DisplayFormat="{0}" Tag="1" ShowInColumn="Qty_IN" />
<dx:ASPxSummaryItem FieldName="HX" SummaryType="Sum" DisplayFormat="{0}"/>
<dx:ASPxSummaryItem FieldName="NA" SummaryType="Sum" DisplayFormat="{0}"/>
</TotalSummary>
</dx:ASPxGridView>
这是填写gridview
的代码:
protected void SourceMain_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
lote = getLot();
device = getDevice();
stage = getStage();
location = getLocation();
equipment = getEquipment();
SD = Convert.ToDateTime(getStartDate());
ED = Convert.ToDateTime(getEndtDate());
MetricsPortal.DAL.ReportsDataClassesDataContext dataContext = new MetricsPortal.DAL.ReportsDataClassesDataContext();
e.Result = (from items in dataContext.CalculateDailyYieldequipmentParam(lote,device,stage,location,equipment,SD,ED,Evaluation())
orderby items.TrackOutDate ascending, items.GRANDTOTAL1 descending
//where items.GRANDTOTAL1 > 0
select items).Distinct();
}//source Main
当这些列的总摘要为0时,是否可以删除或隐藏列?
例如:enter image description here
在黄色列中,值为0,在这种情况下我可以隐藏此列吗?什么时候不是0只显示列?
实际上onselected事件更合适,只要GridView1.Columns[yourcolumnindex].Visible = false;
和列将消失。