Anjali Khan

Anjali Khan

  • NA
  • 867
  • 224.7k

how to search data using start and end date from to db in as

Dec 20 2017 1:16 AM
I created form where i kept 2 calender and search button .
i want to search data using these date like received date and sent date from to data base.how to do this please tell ,
and dispaly in gridview which gv code i attaeched it is on same page
<div>
<p>
<label for="<%= txtstartdate.ClientID %>">
Letter Sent Date(From):</label>
<asp:TextBox ID="txtstartdate" CssClass="text-input small-input" runat="server" MaxLength="10"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Admin/images/cal.jpg"
CausesValidation="false" />
<asp:RequiredFieldValidator ID="RfvStartDate" ValidationGroup="Add" SetFocusOnError="true"
runat="server" ControlToValidate="txtstartdate" Display="Dynamic" ErrorMessage="Please enter start date.">
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RevStartDate" runat="server" ControlToValidate="txtstartdate"
Display="Dynamic" ErrorMessage="Date format should be in dd/mm/yyyy." SetFocusOnError="True"
ValidationExpression="(0[1-9]|[12][0-9]|3[01])[//.](0[1-9]|1[012])[//.](19|20)\d\d"
ValidationGroup="Add">
</asp:RegularExpressionValidator>
<br />
<em><span style="font-size: 8pt; font-weight: bold; color: #459300; font-family: Verdana">Tip:-dd/mm/yyyy</span></em>
</p>
<p>
<label for="<%= txtendate.ClientID %>">
Letter Sent Date(To):</label>
<asp:TextBox ID="txtendate" CssClass="text-input small-input" CausesValidation="true"
runat="server" MaxLength="10"></asp:TextBox>
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/Admin/images/cal.jpg"
CausesValidation="false" />
<asp:RegularExpressionValidator ID="RevEndDate" runat="server" ControlToValidate="txtendate"
Display="Dynamic" ErrorMessage="Date format should be in dd/mm/yyyy." SetFocusOnError="True"
ValidationExpression="(0[1-9]|[12][0-9]|3[01])[//.](0[1-9]|1[012])[//.](19|20)\d\d"
ValidationGroup="Add">
</asp:RegularExpressionValidator>
<asp:CustomValidator ID="CustValEndDate" runat="server" ClientValidationFunction="CheckExpiryDate"
ControlToValidate="txtendate" Display="Dynamic" ErrorMessage="End date must be greater than start date."
ValidationGroup="Add"></asp:CustomValidator>
<br />
<em><span style="font-size: 8pt; color: #459300; font-weight: bold; font-family: Verdana">Tip:-dd/mm/yyyy<%--If u will not enter the end date it will enter the end date after
3 months from start date--%></span></em>
</p>
<p>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd/MM/yyyy" TargetControlID="txtstartdate"
PopupButtonID="ImageButton1">
</cc1:CalendarExtender>
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" Format="dd/MM/yyyy" TargetControlID="txtstartdate">
</cc1:CalendarExtender>
<cc1:CalendarExtender ID="CalendarExtender3" runat="server" Format="dd/MM/yyyy" TargetControlID="txtendate"
PopupButtonID="ImageButton2">
</cc1:CalendarExtender>
<cc1:CalendarExtender ID="CalendarExtender4" runat="server" Format="dd/MM/yyyy" TargetControlID="txtendate">
</cc1:CalendarExtender>
</p>
<div class="form_add_new" id="trdepartmrnt" runat="server">
<div class="row form-group">
<label class="col-md-2 col-xs-12" id="lbldepartment" for="<%=ddlDepartName.ClientID %>">
Department Name<span class="redtext">* </span>:</label>
<div class="col-md-6 col-xs-12">
<asp:DropDownList ID="ddlDepartName" CssClass="form-control" runat="server" AutoPostBack="false"
CausesValidation="false">
</asp:DropDownList>
</div>
</div>
</div>
<div>
<asp:Button ID="BtnSubmit" runat="server" CssClass="btn btn-primary pull-right" ValidationGroup="Add" ToolTip="Click To Save" Text="Search" OnClick="BtnSubmit_Click" EnableTheming="True" />
</div>
</div>
<asp:Panel ID="pnllstgrd" runat="server">
<asp:GridView ID="GrdViewSend" runat="server" AutoGenerateColumns="False"
GridLines="Vertical" Width="100%" CssClass="table-responsive" PageSize="10" AllowPaging="true">
<AlternatingRowStyle CssClass="alt" />
<Columns>
<asp:TemplateField ItemStyle-CssClass="Text-Center" HeaderText="S.No.">
<ItemTemplate>
<%#Container .DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="NO" SortExpression="no" HeaderStyle-CssClass="Text-Center">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "NO")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=" Received Date" SortExpression="receivedate" HeaderStyle-CssClass="Text-Center"
ItemStyle-CssClass="Text-Center">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "ReceivedDate")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="pgr" />
<RowStyle CssClass="drow" Wrap="True" />
</asp:GridView>
</asp:Panel>

Attachment: searchdate.rar

Answers (2)