It seems error is appearing to convert the date or time. I have two files result.aspx and result.aspx.cs. The data will be displayed according to the given 1 day previous date in text box. But it showing error. More detail about error see this url http://playrajshrirashifal.com/result.aspx . Also you can download the code from here. http://playrajshrirashifal.com/test.zip
result.aspx code
<asp:DataList ID="DataList3" runat="server" DataKeyField="Id" DataSourceID="SqlDataSource1">
<asp:DataList ID="DataList2" runat="server" DataKeyField="Id" DataSourceID="SqlDataSource2">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:rajshriConnectionString %>" SelectCommand="SELECT [Id], [LotteryA], [LotteryB], [LotteryC], [Time], [Date] FROM [lottery] WHERE ((CAST([Date] as DATE) = @Date) AND (CAST([Time] as TIME) <= @Time))">
<SelectParameters>
<asp:ControlParameter ControlID="Label2" Name="Date" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="Label1" Name="Time" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:rajshriConnectionString %>" SelectCommand="SELECT [Id], [LotteryA], [LotteryB], [LotteryC], [Time], [Date] FROM [lottery] WHERE ((CAST([Date] as DATE) = @Date) AND (CAST([Date] as DATE) < @Date2))">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox1" Name="Date" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="Label2" PropertyName="Text" Name="Date2" Type="String"></asp:ControlParameter>
</SelectParameters>
</asp:SqlDataSource>
</form>
result.aspx.cs code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class result : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString("t");
Label2.Text = DateTime.Now.ToString("d");
}
protected void Button1_OnClick(object sender, EventArgs e)
{
DataList3.Visible = false;
asd.Visible = false;
}
}
You must add a globalization section to the Web.config file, and then set the uiculture and culture attributes, as shown in the following example:
<globalization uiCulture="es" culture="es-MX" />
Table of Language Culture Names, Codes, and ISO Values Method
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.