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

Grid not displaying data

1 Answer 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lanre Ogunseye
Top achievements
Rank 1
Lanre Ogunseye asked on 23 May 2010, 07:50 AM
HI All,
i am intending to use object data source for a grid below you will find the the snippet of the object i intend calling 
using System; 
using System.Data; 
using System.Configuration; 
using MySql.Data.MySqlClient; 
using Microsoft.ApplicationBlocks.Data; 
 
 
 
/// <summary> 
/// Summary description for CommonDataProvider 
/// </summary> 
namespace com.myclass.DAL 
    public class CommonDataProvider 
    { 
        
 
        public static DataTable getDlr() 
        { 
            DataTable ds= null
            string str = ConfigurationManager.AppSettings["emgConnectionString"]; 
            MySqlConnection con = new MySqlConnection(str); 
            //MySqlCommand command = con.CreateCommand(); 
            string query = "SELECT * FROM routelog"
            //SqlDataAdapter adapter = new SqlDataAdapter(); 
            MySqlDataAdapter myDataAdapter = new MySqlDataAdapter(); 
            myDataAdapter.SelectCommand = new MySqlCommand(query, con); 
            //MySqlDataAdapter myDataAdapter = new MySqlDataAdapter(command); 
            ds= new DataTable(); 
            con.Open(); 
            try 
            { 
                myDataAdapter.Fill(ds); 
            } 
            catch (Exception ex) 
            { 
                WriteLog(DateTime.Now.ToString() + ":" + ex.Message + " " + ex.StackTrace); 
            } 
            finally 
            { 
                con.Close(); 
            } 
            return ds; 
        } 
 
        public static DataSet GetPageInfo()//(int id) 
        { 
            DataSet ds = null
            string str = ConfigurationManager.AppSettings["emgConnectionString"]; 
             
            string sequel = "SELECT routelog.starttime, status.details AS STATUS, routelog.sourceaddr, routelog.destaddr, messagebody.data AS 'encrpted message' FROM emg.routelog INNER JOIN emg.status ON (routelog.status = status.statusID)INNER JOIN emg.messagebody ON (routelog.msgid = messagebody.id)WHERE (routelog.msgtype =1)"
            //if (id > 0) 
            //    sequel += " WHERE ID = " + id; 
 
            //sequel += " ORDER BY PageName"; 
            try 
            { 
                ds = SqlHelper.ExecuteDataset(str, CommandType.Text, sequel); 
            } 
            catch (Exception ex) 
            { 
                WriteLog(DateTime.Now.ToString()+":"+ ex.Message + " " + ex.StackTrace); 
            } 
            return ds; 
        } 
 
        public static void WriteLog(string msg) 
        { 
            try 
            { 
                //HttpContext context = HttpContext.Current; 
                string path = ConfigurationManager.AppSettings["LogFile"]; 
                //string err = ConfigurationManager.AppSettings["LogFile"]; 
                 
                //Mail.SendMail( 
                //string path = context.Server.MapPath(_path); 
                System.IO.StreamWriter writer = new System.IO.StreamWriter(path, true); 
                writer.WriteLine(msg + " " + DateTime.Now.ToString()); 
                writer.WriteLine(); 
                writer.Close(); 
            } 
            catch { } 
        } 
 
         
    } 
 
     
 

below is also the brief of the grid definition
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"  
            SelectMethod="getDlr" TypeName="com.cellulant.DAL.CommonDataProvider"
        </asp:ObjectDataSource> 
<asp:ScriptManager  ID="ScriptManager1" runat="server"></asp:ScriptManager> 
        <!-- content start --> 
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
                <AjaxSettings> 
                    <telerik:AjaxSetting AjaxControlID="RadGrid1"
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                        </UpdatedControls> 
                    </telerik:AjaxSetting> 
                </AjaxSettings> 
            </telerik:RadAjaxManager> 
<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True"  
            AllowPaging="True" AllowSorting="True"  
            GridLines="None" ShowGroupPanel="True" Skin="Sunset" PageSize="50" style="margin-bottom: 117px"  
                                    Width="900px" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1"
<HeaderContextMenu EnableTheming="True"
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
</HeaderContextMenu> 
 
            <ExportSettings FileName="report" IgnorePaging="True" OpenInNewWindow="True"
                <Pdf Creator="cellulant Nigreia Limited" PageHeight="8.5in" PageWidth="11in" /> 
            </ExportSettings> 
 
                                    <PagerStyle Mode="NextPrevNumericAndAdvanced" /> 
 
<MasterTableView DataSourceID="ObjectDataSource1"
<RowIndicatorColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</RowIndicatorColumn> 
 
<ExpandCollapseColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</ExpandCollapseColumn> 
</MasterTableView> 
 
            <ClientSettings AllowColumnHide="True" AllowDragToGroup="True"
                <Selecting AllowRowSelect="True" /> 
                <Scrolling AllowScroll="True" UseStaticHeaders="True" /> 
            </ClientSettings> 
 
<FilterMenu EnableTheming="True"
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
</FilterMenu> 
        </telerik:RadGrid> 

when i used the it did not display the returned record from the getDlr funtion. when i ran it in debug mode i found out the about 2500 record was returned but still the grid will not render the data.

i also tried setting the data source of the grid from code behind it still did not render the data. while it renders them with   sqldatasource.

please  i want to know what am doing wrong. and how to get over it.

thanks

Ogunseye E-Larry

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 24 May 2010, 12:33 PM
Hello Lanre,

You have set AutoGenerateColumns="false" to RadGrid. In this case you either have to define some columns explicitly, or remove that property.

http://www.telerik.com/help/aspnet-ajax/grddesigncolumns.html

http://www.telerik.com/help/aspnet-ajax/grdusingcolumns.html

http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html

All the best,
Dimo
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.
Tags
Grid
Asked by
Lanre Ogunseye
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or