Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have to change the radgrid column header text dynamically according to the data from the db table.
Can you please help about this?
Posted
Updated 11-Sep-16 20:19pm

C#
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridHeaderItem)
    {
        GridHeaderItem header = (GridHeaderItem)e.Item;
        header["ColumnUniqueName"].Text = "Header Text";
    }
}
 
Share this answer
 
Comments
sarath rachuri 29-Jul-14 7:15am    
I had a similar problem of binding headers dynamically. And the above solution perfectly solved the problem and the grid headers are getting binded dynamically. Thanks a lot
C#
protected void grdSearchResult_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.Header)
       {
           for (int j = 0; j < e.Row.Cells.Count; j++)
           {
               TableCell statusCell = e.Row.Cells[j];
               statusCell.Text = statusCell.Text.ToString().Replace('_', ' ');


           //  grdSearchResult.Columns[e.Row.DataItemIndex+1].HeaderText.ToString();
       } }
   }
 
Share this answer
 
Comments
Bernhard Hiller 12-Sep-16 3:21am    
Why do you answer a 4 years old question, which was correctly answered before? And your answer is wrong: the question was about "column header text" and "from database", while you do some change of the cells based on their current content.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900