방법마다 SortDirection.Desc이해당 필드를 초기화하는 방법은 무엇입니까?
private SortDirection s_Sort = SortDirection.Desc;
protected void Page_Load(object sender, EventArgs e)
{
lblSort.Text = S_Sort.ToString();//every time == SortDirection.Desc - this is bad!
if (!IsPostBack)
{
ShowTree();
Validate();
}
}
public void btnSortUp_Click(object sender, EventArgs e)
{
S_Sort = SortDirection.Asc;
}
public void btnSortDown_Click(object sender, EventArgs e)
{
S_Sort = SortDirection.Desc;
}
필요 업데이트하지 s_Sort 그렇게 할 수 있지만 SortDirection.Desc 나쁜 후
것은 당신이 그 다음 SortDirection.Desc 수 wan't하지 않는 경우 : 당신은 포스트 백 사이의 값을 유지하려면, 당신은 개인 재산에서 그것을 캡슐화하여, 예를 들어, viewstate가에 저장할 수 있습니다 매번 할당하지 마십시오 ... 대신해야 할 일은 무엇입니까? – CRice
@CRice, 내가 게시물을 편집 – Mediator