This is a migrated thread and some comments may be shown as answers.

NeedDataSource Not Displaying

3 Answers 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 18 Oct 2010, 08:30 PM
I am new to Telerik controls.  I am attempting to bind data to a rad grid using the NeedDataSource event.  I am using a MySql database.
My current C# code is. 

        protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {

            long ll_error;

            CommandType CommandType = CommandType.Text;

            dbConn = System.Configuration.ConfigurationManager.AppSettings["MYSQLDBConn"].ToString();

            MySqlConnection connection = new MySqlConnection(dbConn);

            connection.Open();

            MySqlCommand command = new MySqlCommand("SELECT * FROM syslookup;", connection);

            command.CommandType = CommandType;

            MySqlDataAdapter _DataAdapter = new MySqlDataAdapter();
            _DataAdapter.SelectCommand = command;

            DataTable myDataTable = new DataTable();

            ll_error = _DataAdapter.Fill(myDataTable);

            RadGrid1.DataSource = myDataTable;
           
        }

In the debugger I can see that the datasource has rows in it, but the grid will not show anything.  It just says no records to display.  Is there something I am missing or some property that needs to be set that I do not know about.  Thanks.

3 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 18 Oct 2010, 10:28 PM
I have discovered it seems to be a problem with a drop down list I have.  I believe it has something to do with the postback.

0
Vasil
Telerik team
answered on 19 Oct 2010, 01:32 PM
Hi Michael,

Your RadGrid1_NeedDataSource function, looks fine. Can you give us the definition of the RadGrid1 in your aspx page, the problem must be hiding in there. Are you using auto generated columns, or you define them declaratively?
I recommend you to look through some of the demos about biding the grid. You can start with this one.

Sincerely yours,
Vasil
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Michael
Top achievements
Rank 1
answered on 19 Oct 2010, 03:40 PM
Thank you for responding to this post.  I'm not sure what caused the problem.  I deleted my original rad grid and made a new one.  This has fixed the problem.  I did this before I saw your post so I do not have the original code.  I agree the problem must have been in there though.  If this happens again I will be sure to include the source code next time.
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or