Click here to Skip to main content
13,054,779 members (71,473 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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]);
            MySqlCommand com = new MySqlCommand("SELECT * FROM processeddata_table WHERE dialdate BETWEEN '" + fromDate + "' AND '" + toDate + "' ", con);
                DataTable ds = new DataTable();
                MySqlDataAdapter da = new MySqlDataAdapter(com);
                GridView1.DataSource = ds;
        protected void Button1_Click(object sender, EventArgs e)
[Edit]Code block added[/Edit]
Posted 26-Mar-13 0:31am
navin ks1.6K
Updated 26-Mar-13 0:54am
onurag19 26-Mar-13 6:42am
Is Gridview Visibility true?
navin ks 26-Mar-13 6:43am
onurag19 26-Mar-13 6:46am
GridView1.DataSource = ds.Tables[0];
Try This.
navin ks 26-Mar-13 6:49am
Error 1 'System.Data.DataTable' does not contain a definition for 'Tables' and no extension method 'Tables' accepting a first argument of type 'System.Data.DataTable' could be found (are you missing a using directive or an assembly reference?) F:\navin\dbdates\dbdates\Default.aspx.cs 46 43 dbdates
onurag19 26-Mar-13 6:52am
Run the query on the Sql Editor or whichever you are using only query check if data exists or not.
And remove the ds.Tables[0];.
Maciej Los 26-Mar-13 6:56am
GridView is a control for WinForms or for WebControls?
navin ks 26-Mar-13 7:09am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

When there is no data the control is not visible.
You have to set the empty data temple to view the grid when there is no data.

First, make sure you are getting some data when using the given query.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Try to set:
AutoGenerateColumns[^] to TRUE and use: EmptyDateText[^] property to display text when gridview's data source does not contain any records.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 26 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100