复选框值不按行进行更新

时间:2011-03-15 08:56:30

标签: c# sql-server-2005

在我的gridview中我有7个复选框,同时更新我最后检查的复选框,它在数据库中更新,其他值已被清除..例如,我们有day_id,因为mon是1,tues为2,wen为3 ,我们4,fri as 5,sun as 7(如果我检查mon和tues复选框意味着,只有tues复选框值已经更新,数据库mon值更新为null。天没有seprate列只有我会通过的日期......

这是我的编码......

if (chkMonday.Checked == true)
    {
        int MonStatus;
        MonStatus = 1;
        SwipeCardLeaveFacade.UpdateCalendarDay(Calenderid, MonStatus, UserContext, RequestContext);
    }
    if (chkTuesday.Checked == true)
    {
        int TueStatus;
        TueStatus = 2;
        SwipeCardLeaveFacade.UpdateCalendarDay(Calenderid, TueStatus, UserContext, RequestContext);
    }
    if (chkWednesday.Checked == true)
    {
        int WedStatus;
        WedStatus = 3;
        SwipeCardLeaveFacade.UpdateCalendarDay(Calenderid, WedStatus, UserContext, RequestContext);
    }
    if (chkThrusday.Checked == true)
    {
        int ThuStatus;
        ThuStatus = 4;
        SwipeCardLeaveFacade.UpdateCalendarDay(Calenderid, ThuStatus, UserContext, RequestContext);
    }
    if (chkFriday.Checked == true)
    {
        int FriStatus;
        FriStatus = 5;
        SwipeCardLeaveFacade.UpdateCalendarDay(Calenderid, FriStatus, UserContext, RequestContext);
    }
    if (chkSaturday.Checked == true)
    {
        int SatStatus;
        SatStatus = 6;
        SwipeCardLeaveFacade.UpdateCalendarDay(Calenderid, SatStatus, UserContext, RequestContext);
    }
    if (chkSunday.Checked == true)
    {
        int SunStatus;
        SunStatus = 7;
        SwipeCardLeaveFacade.UpdateCalendarDay(Calenderid, SunStatus, UserContext, RequestContext);
    }

这是我的存储过程....

Create  Procedure Sp_Update_LMS_CalendarDay  
(    

   @CalendarDay_CalendarID int,    
   @CalendarDay_DayID  int    
)    
as  
update  LMS_CalendarDay  
set  
CalendarDay_CalendarID=@CalendarDay_CalendarID,  
CalendarDay_DayID=@CalendarDay_DayID  
where   
CalendarDay_CalendarID=@CalendarDay_CalendarID

我的表格列是CalendarDay_CalendarID CalendarDay_DayID此处 CalendarDay_DayID 将为1,2,3,4,5,6,7

1 个答案:

答案 0 :(得分:0)

如果我错了,请纠正我。

您所有日期(星期一至星期日)的更新功能使用相同的CalendarId。对于例如我检查了周一和周二。您的存储过程将使用相同的CalendarId调用两次,从而覆盖您的上次更新操作。只有Tues才会在db中更新。