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

Grid view Make rows But didn't come up with Data

3 Answers 33 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Qaiser
Top achievements
Rank 1
Qaiser asked on 25 Jul 2013, 12:18 PM
Hello

Actually i am new to rad controls and i am binding a gridview with a data table.
my gridview makes rows but didn't show data.

my cs code is
    DataTable tblSrc = new DataTable();
               tblSrc.Columns.Add("Title");
               tblSrc.Columns.Add("Time");
               tblSrc.Columns.Add("PrimaryArtist");
               tblSrc.Columns.Add("Album");
               tblSrc.Columns.Add("PrimaryGenre");
               tblSrc.Columns.Add("Rating");
               tblSrc.Columns.Add("Status");
 
               DataRow dr;
               for (int i = 0; i < 5; i++)
               {
                   dr = tblSrc.NewRow();
 
                   dr["Title"] = "asd";
                   dr["Time"] = "asd";
                   dr["PrimaryArtist"] = "Add To PlayList";
                   dr["Album"] = "asd";
                   dr["PrimaryGenre"] = "asd";
                   dr["Rating"] = "asd";
                   dr["Status"] = "asd";
                   tblSrc.Rows.Add(dr);
               }
 
               //DataSet ds = APS.GetAllPodcastsByPublisherId(73);
               this.Gv_SongList.DataSource = tblSrc;
 Pleases anybody tell me why this happen??
any solution?

3 Answers, 1 is accepted

Sort by
0
Qaiser
Top achievements
Rank 1
answered on 27 Jul 2013, 12:58 PM
Actually it is solved.
The only Problem is i turned off the auto generates column Property of radgridview.
i just turned it on and all is working f9 :)
Yohoooooo
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 Jul 2013, 09:08 AM
Hello Qaiser,

Thank you for contacting Telerik Support.

As you have already found out RadGridView.AutoGenerateColumns property gets or sets a value indicating whether columns are created automatically when the DataSource or DataMember properties are set. That is why in your case it is obligatory to be true, because the RadGridView does not know about its structure in advance.

For example if you construct the grid by yourself it is not necessary to enable AutoGenerateColumns:
GridViewColorColumn colorColumn = new GridViewColorColumn("Color column");
GridViewTextBoxColumn textBoxColumn = new GridViewTextBoxColumn("Text column");
 
 this.radGridView1.Columns.Add(colorColumn);
 this.radGridView1.Columns.Add(textBoxColumn);
 
 this.radGridView1.Rows.Add("Red", "Red");
 this.radGridView1.Rows.Add("Yellow", "Yellow");
 this.radGridView1.Rows.Add("Green", "Green");

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Qaiser
Top achievements
Rank 1
answered on 30 Jul 2013, 11:14 AM
Thanx for appreciating me  :)
Tags
GridView
Asked by
Qaiser
Top achievements
Rank 1
Answers by
Qaiser
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or