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

4 posts, 1 answers
  1. Qaiser
    Qaiser avatar
    3 posts
    Member since:
    Jul 2013

    Posted 25 Jul 2013 Link to this post

    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?
  2. Qaiser
    Qaiser avatar
    3 posts
    Member since:
    Jul 2013

    Posted 27 Jul 2013 Link to this post

    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
  3. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3957 posts

    Posted 30 Jul 2013 Link to this post

    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 >>
  4. Qaiser
    Qaiser avatar
    3 posts
    Member since:
    Jul 2013

    Posted 30 Jul 2013 Link to this post

    Thanx for appreciating me  :)
Back to Top