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

How to Get Column Names Form radGrid.

2 Answers 586 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sairam
Top achievements
Rank 1
Sairam asked on 30 Sep 2013, 06:32 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 30 Sep 2013, 09:41 AM
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.
0
Sairam
Top achievements
Rank 1
answered on 01 Oct 2013, 12:59 PM
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...



Tags
General Discussions
Asked by
Sairam
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Sairam
Top achievements
Rank 1
Share this question
or