Custom control not binding the data.

2 posts, 0 answers
  1. Karthick
    Karthick avatar
    2 posts
    Member since:
    Oct 2006

    Posted 21 Dec 2011 Link to this post

    Custom control for telerik grid view in winforms

     In my Windows forms control library:

    for MyGrid.cs (where MyGrid.cs is a component class)

    public MyGrid : ` Telerik.WinControls.UI.RadGridView`

    I build and i have MyGrid.dll & i have added that in my visual studio toolbox (also referenced that dll in my consuming winform app).

    Consuming winform app:

    1. In Form1.cs, i drag and drop that MyGrid  & i write this code:

    >     MyGrid1.DataSource=ds.Table[0]; //Dataset

    The grid doesn't get bound with records, whereas when i check ds `row count it has 150 records`. The grid however shows me green and white color (ie. alternating row color), but doesn't bind the data.

    This is the code that consuming winform uses

           DataSet ds  = null;
           string connectionString = "Data Source=test;Initial Catalog=DBname;Integrated Security=True";
            string sql = " SELECT ID,FirstName from table1 ";
            SqlConnection connection = null;            

             connnection = new SqlConnection(connectionString);
             SqlDataAdapter dataadapter = new SqlDataAdapter(sql, connection);
             ds= new System.Data.DataSet();
             connection.Open();
             dataadapter.Fill(ds, "Table1");
             MyGrid1.DataSource = ds.Tables[0];

    where MyGrid1 is the custom control that is being dragged and dropped from toolbox.

    Custom control code:
                    
      
                this.EnableAlternatingRowColor = true;
                this.TableElement.AlternatingRowColor  = System.Drawing.Color.Green;            
                this.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
                this.AutoGenerateColumns = true;

    The telerik grid is not binding the data, however when i click on the cell, it shows me the value. Any thoughts?
  2. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 23 Dec 2011 Link to this post

    Hi Karthick,

    We experienced similar issues in old versions of RadGridView. However, I am not able to reproduce it with our latest release - Q3 2011 SP1. That is why I recommend that you try our latest release. If the issue continues to appear, please send us your application and we will try to locate it and to find a proper solution.

    Should you have any other questions, please do not hesitate to ask.

    Greetings,
    Jack
    the Telerik team

    Q3’11
    of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top