In my gridview i having 7 checkboxes,while updating the checkbox which i have checked last it is updated in the database other values are been cleared..for eg we have day_id as mon is 1,tues as 2 ,wen as 3,thurs as 4,fri as 5,sat as 6,sun as 7(if i checked mon and tues checkboxes means,only tues check box values are been updated in database mon value is updated as null.there is no seprate column for days only the dayid i will pass....
this is my coding....
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.Updat开发者_如何学JAVAeCalendarDay(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);
}
This is my stored procedure....
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
My table columns is CalendarDay_CalendarID CalendarDay_DayID here CalendarDay_DayID will goes as 1,2,3,4,5,6,7
Correct me if I'm wrong.
Your Update Function for all days (Mon to Sun) is using the same CalendarId
. For e.g. I checked Mon and Tues. Your Stored Procedure will be invoked twice using the same CalendarId
, thus overwriting your last update action. Only Tues will be updated in the db.
精彩评论