/x
модификатор.
/^(
(
( # 31 day months
(0[13578])
| ([13578])
| (1[02])
)
[\/]
(
([1-9])
| ([0-2][0-9])
| (3[01])
)
)
| (
( # 30 day months
(0[469])
| ([469])
| (11)
)
[\/]
(
([1-9])
| ([0-2][0-9])
| (30)
)
)
| ( # 29 day month (Feb)
(2|02)
[\/]
(
([1-9])
| ([0-2][0-9])
)
)
)
[\/]
# year
\d{4}$
| ^\d{4}$ # year only
/x
Оригинал
^((((0[13578])|([13578])|(1[02]))[\/](([1-9])|([0-2][0-9])|(3[01])))|(((0[469])|([469])|(11))[\/](([1-9])|([0-2][0-9])|(30)))|((2|02)[\/](([1-9])|([0-2][0-9]))))[\/]\d{4}$|^\d{4}$
Еще немного посмотрев на код, я наткнулся на значения свойств страницы, хранящиеся в ViewState. Как только я переключился на сеанс, они работают.
Dumb idea, but have you checked the page load event with the if(!Page.IsPostBack)
?
From ASP.NET Page Framework Overview :
Page_Load: During this event, you can perform a series of actions to either create your ASP.NET page for the first time or respond to client-side events that result from a post. The page and control view state have been restored prior to this event. Use the IsPostBack page property to check whether this is the first time that the page is being processed. If it is the first time, perform data binding. Also, read and update control properties.
Where as
Page_PreRender: The PreRender event is fired just before the view state is saved and the controls are rendered. You can use this event to perform any last minute operations on your controls.
In effect
Because the page framework is a stateless a and disconnected model, every time a client requests an .aspx page, many things occur during the page processing ...
So in effect, you could be doing your checking before the viewstate is being set rather than after the viewstate has been restored. The most common place to check for if(!Page.IsPostBack)
is typically in the Page_Load event.
В вашем примере показано
TestGridView.Columns.RemoveAt(0);
, но действительно ли вы имели в виду
TestGridView.Rows.RemoveAt(0);
(и в этом ли проблема?)
У меня была аналогичная проблема с динамической привязкой TreeView к XmlDataSource, который менял источник xml при каждой обратной передаче. Установка EnableCache на false исправила это. Вы пробовали это? (Учтите, что объект Linq2sql уже кэшируется, если ваш IQueryable использует объект Linq2sql, то есть)
<asp:ObjectDataSource ID="TestDataSource" runat="server" EnableCaching="false"
EnablePaging="true" SelectCountMethod="GetDetailCount"
SelectMethod="GetDetails" TypeName="MyApp.PageClass" />
, если это не работает, попробуйте это вместе с приведенным выше:
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
BindData();
}
Gridviews не перепривязываются при postback, их строки возвращаются из состояния просмотра. Сброс DatasourceID гридвью на ID источника данных объекта при загрузке страницы (или при инициализации?) приведет к перепривязке гридвью.