我對這個問題感到抱歉,但不知何故我有一個停電(我知道它不是藉口),但我怎麼能從RadNumbericTextBox
檢索值使用按鈕發送值(我需要一個INT)如何從RadNumericTextBox檢索值
<div class="fromRowDiv">
<asp:Label ID="label1" CssClass="fromLabel" runat="server" Text="From Date" ></asp:Label>
<telerik:RadNumericTextBox ID="fromYear" runat="server" MinValue="2000" NumberFormat-DecimalDigits="0" NumberFormat-GroupSeparator="" ></telerik:RadNumericTextBox>
<asp:Label ID="Tolabel2" CssClass="fromLabel" runat="server" Text="To Date"></asp:Label>
<telerik:RadNumericTextBox ID="toYear" runat="server" MinValue="2000" NumberFormat-DecimalDigits="0" NumberFormat-GroupSeparator=""></telerik:RadNumericTextBox>
</div>
protected void CalcButton_Click(object sender, EventArgs e)
{
AnnualVacationManager mng = new AnnualVacationManager();
mng.CalcForNextYear(fromYear,toYear);
}
我需要從RadNumbericTextBox值(動態)
public AnnualVacationManager() {
}
public void CalcForNextYear(int fromYear, int toYear)
{
IEnumerable<HtUser> allUsers = HtUser.GetAll();
List<AnnualVacation> newAnnualVacations = new List<AnnualVacation>();
if (allUsers.Any()) {
foreach (HtUser user in allUsers) {
//int fromYear = 2013;
//int toYear = 2014;
IEnumerable<AnnualVacation> usersCurrentAnnualVacation = new List<AnnualVacation>(user.AnnualVacations.Where(a =>a.FromDate.Value.Year >= fromYear && a.FromDate.Value.Year < toYear));
if (usersCurrentAnnualVacation.Any()) {
foreach (AnnualVacation existing in usersCurrentAnnualVacation) {
AnnualVacation newAnnualVacation = new AnnualVacation();
//Year stuff
DateTime newFromDate = existing.FromDate.Value;
newFromDate.AddYears(toYear - fromYear);
DateTime newToDate = existing.ToDate.Value;
newToDate.AddYears(toYear - fromYear);
//
newAnnualVacation.FromDate = newFromDate;
newAnnualVacation.ToDate = newToDate;
newAnnualVacation.WorkingTime = existing.WorkingTime;
newAnnualVacation.VacationDays = existing.VacationDays + (existing.VacationDays - user.GetBookedVacation(fromYear));
newAnnualVacations.Add(newAnnualVacation);
newAnnualVacation.HtUser = user;
}
}
}
HtEntityFactory.Context.SaveChanges();
}
}
}
}
我在答案上非常堅實,直到我看到您的文章(動態)中的最後一個單詞。 「動態」是什麼意思? – 2013-02-21 13:29:45
只是不是靜態,以獲得從RadNumericTextBox鍵入的值 – Mingebag 2013-02-21 13:35:07