过滤两个日期之间的数据 [英] filter the data between two dates

查看:61
本文介绍了过滤两个日期之间的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我在页面上按两个日期过滤数据,这些数据来自两个文本框
当两个文本框中的月份相同时,但是当我更改月份时,则没有给出任何内容

Hello,


On a page i m filtering data by two dates those are taken from two text boxes
when the month is same in both text boxes but when i change my month then did not give any thing

推荐答案


试试这个:
Hi,
Try this:
protected void Button1_Click1(object sender, EventArgs e) 
{ 
    DateTime dt1 = Convert.ToDateTime(TextBox1.Text); 
    DateTime dt2 = Convert.ToDateTime(TextBox2.Text); 
    con.Open(); 
    SqlCommand cmd = new SqlCommand("select 'Ch.No'=SNO,'Date'=DATE,'Particulars'=PNAME,'Qty'=QUANT,'Rate'=RATE,'Amount'=TOTAL,'Balance'=BALANCE from BILL1 where CNAME=@Cname and DATE between @FromDate and @ToDate", con)
    cmd.CommandType = CommandType.Text;
    cmd.Parameters.add("@Cname", DropDownList1.SelectedItem.Text);
    cmd.Parameters.add("@FromDate", dt1);
    cmd.Parameters.add("@ToDate", dt2);
    SqlDataAdapter da = new SqlDataAdapter(cmd); 
    DataSet ds = new DataSet(); 
    da.Fill(ds); 
    GridView1.DataSource = ds; 
    GridView1.DataBind(); 
    con.Close(); 
    Button3.Visible = true; 
}




祝一切顺利.
--Amit




All the best.
--Amit


这篇关于过滤两个日期之间的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆