从数据库显示错误的值 [英] Wrong values are been display from database

查看:70
本文介绍了从数据库显示错误的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的学校列表已显示在下拉列表框中。当用户选择学校时,将显示关于学校的所有信息。用户还可以使用页面中的编辑按钮编辑信息。在编辑中,我有一个名为学生工作时间的字段,我们有开始和结束时间。用户可以在单独的框中填写小时和分钟。在给出值并单击保存按钮时,将保存更新值的值,并将显示在特定学校的主页中。我面临的问题是,我在一些学校只显示了我在分钟框中输入的值00,并且我为其他学校显示了我输入的正确值。我无法找到为什么单独的分钟值仅为学校而变成00。任何人都可以帮我解决这个问题。



 if(SelectedSchool.StudentStartTime!= null&& SelectedSchool.StudentEndTime!= null)
{
TimeSpan openingTime =(TimeSpan)SelectedSchool.StudentStartTime.Value;
TimeSpan closingTime =(TimeSpan)SelectedSchool.StudentEndTime.Value;

uxStudentOpeningHour.Text = openingTime.Hours.ToString();
uxStudentOpeningMin.Text = openingTime.Minutes.ToString();
uxStudentClosingHour.Text = closingTime.Hours.ToString();
uxStudentClosingMin.Text = closingTime.Minutes.ToString();

ltStudentOpenningHours.Text = SelectedSchool.StudentStartTime.Value.ToString(hh\\:mm)
+to+ SelectedSchool.StudentEndTime.Value.ToString(hh \\ \\\:MM);
}





以上代码用于保存在小时和分钟框中输入的值。< br $> b $ b

 protected void btnSave_OnClick(object sender,EventArgs e)
{
if(Save())
{
if(OnSave!= null)
{
EventArgs newArgs = new EventArgs();
OnSave(this,newArgs);
}
}
其他
{
phErrorMessage.Visible = true;
}
}





为保存按钮点击功能定义的上述功能。

解决方案

我不知道你的网页上有什么,但我认为你应该使用TimeTime时使用TimeSpan。定义:



 DateTime openingTime,closingTime; 





然后得到时间差



 TimeSpan timeInbetween = closingTime  -  openingTime; 


I have list of schools been displayed in the drop down list box. when a user selects a school all the information about school will be displayed. The user can also edit the information using the edit button in the page. In the edit I have field named as "student working hours" where we have start and end time. The user can fill in the hours and also minutes in separate boxes. As the values are given and save button is clicked the values the updated values will be saved and will be displayed in the home page of the particular school. The issue I face is that the whatever values I enter in the mins box only 00 is been displayed for some schools and the correct value I entered is been displayed for other schools. I am unable to find why the values for the minutes alone becomes 00 only for schools alone. Can anyone help me to fix this issue.

if (SelectedSchool.StudentStartTime != null && SelectedSchool.StudentEndTime != null)
       {
           TimeSpan openingTime = (TimeSpan)SelectedSchool.StudentStartTime.Value;
           TimeSpan closingTime = (TimeSpan)SelectedSchool.StudentEndTime.Value;

           uxStudentOpeningHour.Text = openingTime.Hours.ToString();
           uxStudentOpeningMin.Text = openingTime.Minutes.ToString();
           uxStudentClosingHour.Text = closingTime.Hours.ToString();
           uxStudentClosingMin.Text = closingTime.Minutes.ToString();

           ltStudentOpenningHours.Text = SelectedSchool.StudentStartTime.Value.ToString("hh\\:mm")
               + " to " + SelectedSchool.StudentEndTime.Value.ToString("hh\\:mm");
       }



The above code is to save the values been entered in the hours and minutes boxes.

protected void btnSave_OnClick(object sender, EventArgs e)
   {
       if (Save())
       {
           if (OnSave != null)
           {
               EventArgs newArgs = new EventArgs();
               OnSave(this, newArgs);
           }
       }
       else
       {
           phErrorMessage.Visible = true;
       }
   }



The above function defined for save button click function.

解决方案

I don't know what's on your web page, however I think you're using TimeSpan when you should use DateTime. Define:

DateTime openingTime, closingTime;



then get the time difference with

TimeSpan timeInbetween = closingTime - openingTime;


这篇关于从数据库显示错误的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆