How to Get Column Names Form radGrid.

3 posts, 1 answers
  1. Sairam
    Sairam avatar
    56 posts
    Member since:
    May 2013

    Posted 30 Sep 2013 Link to this post

    Hello Team,

    1.I have situation  like these I want bind The "Header Text"  of  All Column to "rad List-box" .. after The Need Data Source  is Binded .

    How to get Column Name server side which event is Better for that to write the code.. can Help heir to get the "Column Name " Of  "rad Grid".



    Thanks & Regards,
    Sairam Pamidi
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 30 Sep 2013 Link to this post

    Hi,

    I guess you want to get the HeaderText of all columns in RadGrid and Bind it to a RadListBox. Please take a look into the following code snippet.

    C#:
    protected void RadgRid1_PreRender(object sender, EventArgs e)
    {
            ArrayList dataSource = new ArrayList();    
            foreach (GridHeaderItem itm in RadgRid1.MasterTableView.GetItems(GridItemType.Header))
            {
                foreach (GridColumn col in RadgRid1.MasterTableView.Columns)
                {
                    dataSource.Add(itm[col.UniqueName].Text);
                }
                RadListBox1.DataSource = dataSource;
                RadListBox1.DataBind();
            }
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sairam
    Sairam avatar
    56 posts
    Member since:
    May 2013

    Posted 01 Oct 2013 Link to this post

    protected void RadGrid1_PreRender(object sender, EventArgs e)
       {
     
     
           List<string> dataSource = new List<string>();
           foreach(GridHeaderItem itm in RadGrid1. MasterTableView.GetItems(GridItemType.Header))
           {
               foreach (GridColumn col in RadGrid1.MasterTableView.Columns)
               {
                   if (itm[col.UniqueName].Text != string.Empty && itm[col.UniqueName].Text !=" ")
                   {
                       dataSource.Add(itm[col.UniqueName].Text);
                   }
               }
               RadLtbSltAll.DataSource = dataSource;
               RadLtbSltAll.DataBind();
           }
            
       }


    Thanks  Princy, It Working Fine


    The Below Code With out  Getting the "&nbsp; "In "RadlistBox"  it may useful to Some like Me...



Back to Top