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

Custom control not binding the data.

1 Answer 51 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Karthick
Top achievements
Rank 1
Karthick asked on 21 Dec 2011, 11:52 PM
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?

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 23 Dec 2011, 11:22 AM
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.
Tags
GridView
Asked by
Karthick
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or