本文介绍了gridview不可见;(..没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void BindDates()
        {

            DateTime FromDate = DateTime.Now.ToUniversalTime().AddHours(5.5);

            TxtFromDate.Text = FromDate.ToString("yyyy/MM/dd");

            DateTime ToDate = DateTime.Now.ToUniversalTime().AddHours(5.5);

            TxtToDate.Text = ToDate.ToString("yyyy/MM/dd");

        }
        protected void databind()
        {
            string[] strFromDate = TxtFromDate.Text.Split('/');
            string[] strToDate = TxtToDate.Text.Split('/');

            DateTime fromDate = Convert.ToDateTime(strFromDate[1] + '/' + strFromDate[2] + '/' + strFromDate[0]);
            DateTime toDate = Convert.ToDateTime(strToDate[1] + '/' + strToDate[2] + '/' + strToDate[0]);
            con.Open();
            MySqlCommand com = new MySqlCommand("SELECT * FROM processeddata_table WHERE dialdate BETWEEN '" + fromDate + "' AND '" + toDate + "' ", con);
            {
                DataTable ds = new DataTable();
                MySqlDataAdapter da = new MySqlDataAdapter(com);
                da.Fill(ds);
                GridView1.DataSource = ds;
                GridView1.DataBind();
                con.Close();
                da.Dispose();
                ds.Dispose();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            databind();
        }
    }

已添加代码块[/ Edit]

Code block added[/Edit]

推荐答案



这篇关于gridview不可见;(..没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 10:39