Sir,
In my project I am having great problem while quering with date
on my page I have two textboxes as starting and ending date and having Ajax Calander Control on them
If I set date format in Ajax control as dd/MM/yyyy it raises error while searching on date period range
Pl. guide how to solve this so that I work everywhere
Here are the codes
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Accounts_Default" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<style type="text/css">
.style1
{
text-align: center;
}
.style2
{
width: 763px;
height: 233px;
border: 1px solid #c0c0c0;
}
.style3
{
width: 2109px;
height: 64px;
}
.style4
{
width: 328px;
height: 64px;
}
.style5
{
width: 2109px;
text-align: center;
}
.style6
{
width: 743px;
text-align: center;
}
.style7
{
width: 743px;
height: 64px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<p class="style1">
Firms Payment Inquiry
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table class="style2">
<tr>
<td class="style6">
Firm Name</td>
<td class="style5">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:DropDownList ID="cbofirmname" runat="server" DataSourceID="firmsql"
DataTextField="NAME" DataValueField="CODE" Width="445px">
</asp:DropDownList>
<asp:SqlDataSource ID="firmsql" runat="server"
ConnectionString="<%$ ConnectionStrings:accountsConnectionString %>"
SelectCommand="SELECT [CODE], [NAME] FROM [FIRM] ORDER BY [NAME]">
</asp:SqlDataSource>
</td>
</tr>
<tr>
<td class="style7">
Period
</td>
<td class="style3">
<asp:TextBox ID="st_date" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="st_date_CalendarExtender" runat="server"
Enabled="True" TargetControlID="st_date" Format = "MM/dd/yyyy">
</asp:CalendarExtender>
To
<asp:TextBox ID="end_date" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="end_date_CalendarExtender" runat="server"
Enabled="True" TargetControlID="end_date" Format = "MM/dd/yyyy">
</asp:CalendarExtender>
<asp:Button ID="cmdshowdetails" runat="server" Height="22px" Text="Show Details"
Width="88px" />
<asp:Button ID="cmdprint" runat="server" Text="Print" />
</td>
</tr>
<tr>
<td class="style7">
</td>
<td class="style3">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False"
Height="16px" Width="673px"
EmptyDataText=""Sorry No Result to Show"">
<Columns>
<asp:BoundField DataField="BILL_AMT" HeaderText="BILL_AMT"
SortExpression="BILL_AMT" />
<asp:BoundField DataField="TR_DATE" HeaderText="TR_DATE"
SortExpression="TR_DATE" />
<asp:BoundField DataField="CHNO" HeaderText="CHNO" SortExpression="CHNO" />
<asp:BoundField DataField="VNO" HeaderText="VNO" SortExpression="VNO" />
<asp:BoundField DataField="VAT" HeaderText="VAT" SortExpression="VAT" />
<asp:BoundField DataField="srtax" HeaderText="srtax" SortExpression="srtax" />
<asp:BoundField DataField="TDS" HeaderText="TDS" SortExpression="TDS" />
<asp:BoundField DataField="NET_PAY" HeaderText="NET_PAY"
SortExpression="NET_PAY" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="firmdtsql" runat="server"
ConnectionString="<%$ ConnectionStrings:accountsConnectionString %>"
SelectCommand="SELECT BILL_AMT, TR_DATE, CHNO, VNO, VAT, srtax, TDS, NET_PAY FROM FIRMDT WHERE (CODE = @CODE) AND (TR_DATE BETWEEN @TR_DATE AND @TR_DATE2)">
<SelectParameters>
<asp:ControlParameter ControlID="cbofirmname" Name="CODE"
PropertyName="SelectedValue" Type="Double" />
<asp:ControlParameter ControlID="st_date" Name="TR_DATE" PropertyName="Text"
Type="DateTime" />
<asp:ControlParameter ControlID="end_date" Name="TR_DATE2" PropertyName="Text"
Type="DateTime" />
</SelectParameters>
</asp:SqlDataSource>
<asp:Button ID="Button1" runat="server" Text="Button"
PostBackUrl="~/Accounts/Default2.aspx" Visible="False" />
<asp:Label ID="Label1" runat="server" Text="Label1"></asp:Label>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</p>
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"
AutoDataBind="true" ClientIDMode="Predictable" ShowAllPageIds="True"
ToolPanelView="None" ViewStateMode="Enabled" />
<asp:Button ID="btnGenerate" runat="server" Text="Generate Report" />
</asp:Content>
Protected Sub cmdshowdetails_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdshowdetails.Click, GridView1.PageIndexChanged
Dim stdate, enddate As Date
Dim dt As DateTime = DateTime.Parse(st_date.Text, System.Globalization.CultureInfo.GetCultureInfo("en-gb"))
'Get only Datepart from the above converted value
stdate = Convert.ToDateTime(dt.ToShortDateString())
'Convert your Datetime value
Dim dt1 As DateTime = DateTime.Parse(end_date.Text, System.Globalization.CultureInfo.GetCultureInfo("en-gb"))
'Get only Datepart from the above converted value
enddate = Convert.ToDateTime(dt1.ToShortDateString())
Dim SqlDataSource1 As New SqlDataSource()
' If Not IsPostBack Then
SqlDataSource1.ID = "sqlfirmdt"
Me.Page.Controls.Add(SqlDataSource1)
SqlDataSource1.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("accountsConnectionString").ConnectionString
SqlDataSource1.SelectCommand = "select tr_date,chno,vno,bill_amt,tds,vat,srtax,net_pay from firmdt where code=" & cbofirmname.SelectedValue & " and cast(CONVERT(varchar(8), tr_date, 112) AS datetime) between '" & stdate & "' and '" & enddate & "' order by tr_date desc "
GridView1.DataSource = SqlDataSource1
GridView1.DataBind()
'End If
End Sub