Click here to Skip to main content
16,012,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone

I am using gridview with columns Startdate, enddate and price

I need to check that if user enters price for 365 days

Ex :

startdate enddate Price
--------- ------- -----
1/1/2011 28/2/2011 100
1/3/2011 2/5/2011 100
3/5/2011 1/7/2011 250
10/7/2011 15/9/2011 200---- there is a gap of days(there no price From 2/7/2011 till 9/7/2011)
17/9/2011 1/11/2011 100 ----there is a gap of 1 days(there is no price for day 16/9/2011)
17/11/2011 31/12/2011 100-----there is gap of 16 days (there is no price from 2/11/2011 till 16/11/2011)

How do i find missing days for which price is not entered in a year in grid??
Posted
Updated 7-Sep-11 4:38am
v5
Comments
[no name] 7-Sep-11 9:05am    
post what you have done so far, let us take a look and correct the mistake
Mythri_8 19-Sep-11 8:00am    
i am not able to paste my entire code as a reply to this comment

@Maulik
I have a gridview, which is as below

<asp:GridView ID="gvShortStayRate" runat="server" AutoGenerateColumns="False"
BorderColor="Black" BorderWidth="1px" DataKeyNames="Id"
DataSourceID="ShortTermRateDS" OnRowCommand="gvShortStayRate_RowCommand"
ShowFooter="True">
<Columns>

<asp:TemplateField HeaderText="First night">
<EditItemTemplate>
<asp:TextBox ID="Editstart_date" runat="server" Height="15px" ReadOnly="True"
Text='<%# Bind("start_date") %>' Width="65px" />
<asp:CalendarExtender ID="calstart_date" runat="server" Enabled="True" Format="dd/MM/yyyy"
PopupButtonID="img_calendarstart" TargetControlID="Editstart_date"></asp:CalendarExtender>
<asp:Image ID="img_calendarstart" runat="server" ImageUrl="Images/Calendar_scheduleHS.png" />
<asp:RequiredFieldValidator ID="RFVEditStartDate" runat="server" ControlToValidate="Editstart_date"
ErrorMessage="*" ValidationGroup="Edit"></asp:RequiredFieldValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="Insertstart_date" runat="server" Height="15px" ReadOnly="True"
Text='<%# Bind("start_date") %>' Width="65px" />
<asp:CalendarExtender ID="calInsertstart_date" runat="server" Enabled="True"
Format="dd/MM/yyyy" PopupButtonID="imgcalendarInsertstart"
TargetControlID="Insertstart_date"></asp:CalendarExtender>
<asp:Image ID="imgcalendarInsertstart" runat="server"
ImageUrl="Images/Calendar_scheduleHS.png" />
<asp:RequiredFieldValidator ID="RFVInsertStartDate" runat="server"
ControlToValidate="Insertstart_date" ErrorMessage="*" ValidationGroup="Insert"></asp:RequiredFieldValidator>
</FooterTemplate>
<ItemTemplate>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Last night">
<EditItemTemplate>
<asp:TextBox ID="Editend_date" runat="server" Height="15px" ReadOnly="True"
Text='<%# Bind("end_date") %>' Width="65px" />
<asp:CalendarExtender ID="calEditend_date" runat="server" Enabled="True" Format="dd/MM/yyyy"
PopupButtonID="imgcalendarEditend" TargetControlID="Editend_date"></asp:CalendarExtender>
<asp:Image ID="imgcalendarEditend" runat="server" ImageUrl="Images/Calendar_scheduleHS.png" />
<asp:RequiredFieldValidator ID="RFVEditEndDate" runat="server" ControlToValidate="Editend_date"
ErrorMessage="*" ValidationGroup="Edit"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CVEnddate" runat="server" ControlToCompare="EditStart_date"
ControlToValidate="Editend_date" ErrorMessage="end date should be greater than start date"
Operator="GreaterThan" ValidationGroup="Edit"></asp:CompareValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="Insertend_date" runat="server" Height="15px" ReadOnly="True"
Text='<%# Bind("end_date") %>' Width="65px" />
<asp:CalendarExtender ID="calInsertend_date" runat="server" Enabled="True"
Format="dd/MM/yyyy" PopupButtonID="imgcalendarInserttend"
TargetControlID="Insertend_date"></asp:CalendarExtender>
<asp:Image ID="imgcalendarInserttend" runat="server"
ImageUrl="Images/Calendar_scheduleHS.png" />
<asp:RequiredFieldValidator ID="RFVInsertEndDate" runat="server"
ControlToValidate="Insertend_date" ErrorMessage="*" ValidationGroup="Insert"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CVInsertEnddate" runat="server"
ControlToCompare="Insertstart_date" ControlToValidate="Insertend_date"
ErrorMessage="end date should be greater than start date"
Operator="GreaterThan" ValidationGroup="Insert"></asp:CompareValidator>
</FooterTemplate>
<ItemTemplate>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Weekly rate">
<EditItemTemplate>
<asp:TextBox ID="Editweekly_rate" runat="server" Height="15px"
Text='<%# Bind("weekly_rate") %>' Width="50px" />
<asp:RequiredFieldValidator ID="RFVWeeklyRate" runat="server" ControlToValidate="Editweekly_rate"
ErrorMessage="*" ValidationGroup="Edit"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CVWeeklyRate" runat="server" ControlToValidate="Editweekly_rate"
ErrorMessage="Enter Valid Rate" Operator="DataTypeCheck" Type="Double"
ValidationGroup="Edit"></asp:CompareValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="Insertweekly_rate" runat="server" Height="15px"
Text='<%# Bind("weekly_rate") %>' Width="50px" />
<asp:RequiredFieldValidator ID="RFVInsertWeeklyRate" runat="server"
ControlToValidate="Insertweekly_rate" ErrorMessage="*" ValidationGroup="Insert"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CVInsertWeeklyRate" runat="server"
ControlToValidate="Insertweekly_rate" ErrorMessage="Enter Valid Rate"
Operator="DataTypeCheck" Type="Double" ValidationGroup="Insert"></asp:CompareValidator>
</FooterTemplate>
<ItemTemplate>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Commands">
<EditItemTemplate>
<asp:Button ID="Update" runat="server" CommandArgument='<%#Eval("id") %>'
CommandName="Update" Text="Update" ValidationGroup="Edit" />
<asp:Button ID="Cancel" runat="server" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="Insert" runat="server" CommandName="InsertNew" Text="Insert"
ValidationGroup="Insert" />
</FooterTemplate>
<ItemTemplate>
<asp:Button ID="Edit" runat="server" CommandName="Edit" Text="Edit" />
<asp:Button ID="Delete" runat="server" CommandName="Delete" Text="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>

First night:<asp:TextBox ID="NoDatastart_date" runat="server" Height="15px" ReadOnly="True"
Text='<%# Bind("start_date") %>' Width="65px" />
<asp:CalendarExtender ID="calNoDatastart_date" runat="server" Enabled="True" Format="dd/MM/yyyy"
OnClientDateSelectionChanged="DateSelected" PopupButtonID="imgcalendarNodatatstart" TargetControlID="NoDatastart_date"></asp:CalendarExtender>
<asp:Image ID="imgcalendarNodatatstart" runat="server" ImageUrl="Images/Calendar_scheduleHS.png" />
<asp:RequiredFieldValidator ID="RFVNoDatastartdate" runat="server" ControlToValidate="NoDatastart_date"
ErrorMessage="*" ValidationGroup="NoDataInsert"></asp:RequiredFieldValidator>
Last night:<asp:TextBox ID="NoDataend_date" runat="server" Height="15px" ReadOnly="True"
Text='<%# Bind("end_date") %>' Width="65px" />
<asp:CalendarExtender ID="calNoDataend_date" runat="server" Enabled="True" Format="dd/MM/yyyy"
PopupButtonID="imgcalendarNodatatend" TargetControlID="NoDataend_date"></asp:CalendarExtender>
<asp:Image ID="imgcalendarNodatatend" runat="server"
ImageUrl="Images/Calendar_scheduleHS.png" />
<asp:RequiredFieldValidator ID="RFVNodataEndDate" runat="server" ControlToValidate="NoDataend_date"
ErrorMessage="*" ValidationGroup="NoDataInsert"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CVNodataEnddate" runat="server" ControlToCompare="NoDatastart_date"
ControlToValidate="NoDataend_date" ErrorMessage="end date should be greater than start date"
Operator="GreaterThan" ValidationGroup="NoDataInsert"></asp:CompareValidator>
Weekly rate:<asp:TextBox ID="NoDataweekly_rate" runat="server" Height="15px"
Text='<%# Bind("weekly_rate") %>' Width="50px" />
<asp:RequiredFieldValidator ID="RFVNodataWeeklyRate" runat="server" ControlToValidate="NoDataweekly_rate"
ErrorMessage="*" ValidationGroup="NoDataInsert"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CVNoDataWeeklyRate" runat="server" ControlToValidate="NoDataweekly_rate"
ErrorMessage="Enter Valid Rate" Operator="DataTypeCheck" Type="Double" ValidationGroup="NoDataInsert"></asp:CompareValidator>
</EmptyDataTemplate>
<RowStyle BorderColor="Beige" BorderWidth="1px" />
</asp:GridView>

User can enter startdate,enddate and price.Once user clicks on Insert this record is saved in database.
What i have to do now is check whether startdate,enddate and price is entered for 12 months (365 days) or check if there is any missing days for which price is not entered and alert user.
 
Share this answer
 
Comments
sandipMarvaniya 19-Sep-11 12:16pm    
thnx
you can compare a enddate and start date between two rows.means check the startdate of nextrow will bethe next date of previous endadte. take difference between these two dates
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900