Click here to Skip to main content
11,806,575 members (67,732 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# MySQL
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.5K
Edited 26-Mar-13 0:54am
onurag19 at 26-Mar-13 6:42am
Is Gridview Visibility true?
navin ks at 26-Mar-13 6:43am
onurag19 at 26-Mar-13 6:46am
GridView1.DataSource = ds.Tables[0];
Try This.
navin ks at 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 at 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 at 26-Mar-13 6:56am
GridView is a control for WinForms or for WebControls?
navin ks at 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
0 ppolymorphe 205
1 OriginalGriff 175
2 Richard Deeming 175
3 Sergey Alexandrovich Kryukov 170
4 Abhinav S 120
0 OriginalGriff 3,380
1 Maciej Los 1,990
2 CPallini 1,915
3 KrunalRohit 1,907
4 ppolymorphe 1,317

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 26 Mar 2013
Copyright © CodeProject, 1999-2015
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