如何在aspxgridview中禁用GridViewDataDateColumn中的过去日期

时间:2016-11-23 09:55:17

标签: devexpress

<dx:GridViewDataDateColumn FieldName="ScheduledTimeForDelivery" Caption="Scheduled Time For Delivery" Width="14%" VisibleIndex="5">
                                        <Settings AutoFilterCondition="Contains" />

                                        <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Font-Bold="True" Wrap="True" />

                                        <PropertiesDateEdit  DisplayFormatString="dd/MM/yyyy hh:mm tt" EditFormatString="dd/MM/yyyy hh:mm tt">
                                            <TimeSectionProperties Visible="true">
                                                <TimeEditProperties EditFormatString="hh:mm tt" EditFormat="Custom"></TimeEditProperties>
                                            </TimeSectionProperties>

                                            <ValidationSettings RequiredField-IsRequired="true" ErrorTextPosition="Bottom" ErrorDisplayMode="Text">
                                                <RequiredField ErrorText="Please enter the Scheduled Time For Delivery" />
                                            </ValidationSettings>

                                        </PropertiesDateEdit>
                                        <EditFormSettings VisibleIndex="3" />
                                    </dx:GridViewDataDateColumn>

我想在我的列“ScheduledTimeForDelivery”中禁用之前的所有日期,如何禁用它以前的日期。

2 个答案:

答案 0 :(得分:0)

参考: ASPxGridview - date column

使用编辑器的MaxDateMinDate属性来实现此目的。例如:

GridViewDataDateColumn dateColumn = gridView.Columns["ScheduledTimeForDelivery"] as GridViewDataDateColumn;
dateColumn.PropertiesDateEdit.MaxDate = System.DateTime.Now.AddYears(5);
dateColumn.PropertiesDateEdit.MinDate = System.DateTime.Now.AddYears(-5);

或者您可以在文档的帮助下设法在aspx页面中执行此操作。

Disabling specific dates in ASPxDateEdit, in Edit form of ASPxGridView

希望这有帮助..

答案 1 :(得分:0)

在单元格编辑器中使用此行初始化甚至

 if (e.Column.FieldName == "ScheduledTimeForDelivery")
                (e.Editor as ASPxDateEdit).MinDate = DateTime.Now.Date;