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

Changing text on header

2 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tony Deo
Top achievements
Rank 1
Tony Deo asked on 14 Oct 2009, 11:27 AM
I am trying to change the text on the header columns of the RADGRID.  I have added the relevant code to the ItemDataBound event and it's working fine, when thepage loads the text dynamically changes.  However, when I select the row with the select button the header title revert back to the original.  Do I need to add additional code in the SelectedIndexChanged and if so what?

I have posted the code in the ItemDataBound below:

If Profile.UserCulture = 2 Then  
            If TypeOf e.Item Is GridHeaderItem Then  
                Dim header As GridHeaderItem = DirectCast(e.Item, GridHeaderItem)  
                header("PRN").Text = "购买申请编号" 
                header("RaisedBy").Text = "提出者" 
                header("Supplier").Text = "供应商" 
                header("DeliveryRequired").Text = "要求送货日期" 
                header("PRNotes").Text = "附注及特别说明" 
                header("ReqValue").Text = "价值" 
                header("Status").Text = "状态" 
                header("Level1").Text = "第 1 级授权" 
                header("Level2").Text = "第 2 级授权" 
                header("POSNumber").Text = "采购订单编号" 
            End If  
        End If 

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 14 Oct 2009, 11:59 AM
Hello Tony,

You can try adding the code in the PreRender event, since when you make changes in the ItemDataBound, it does not persist. Check out the example below:
vb:
 
Protected Sub RadGrid1_PreRender(sender As Object, e As EventArgs)  
    If Profile.UserCulture = 2 Then  
        For Each headerItem As GridHeaderItem In RadGrid1.MasterTableView.GetItems(GridItemType.Header)  
            header("PRN").Text = "购买申请编号"  
            header("RaisedBy").Text = "提出者"  
            header("Supplier").Text = "供应商"  
            header("DeliveryRequired").Text = "要求送货日期"  
            header("PRNotes").Text = "附注及特别说明"  
            header("ReqValue").Text = "价值"  
            header("Status").Text = "状态"  
            header("Level1").Text = "第 1 级授权"  
            header("Level2").Text = "第 2 级授权"  
            header("POSNumber").Text = "采购订单编号"  
        Next  
    End If  
End Sub  

Thanks
Princy.
0
Tony Deo
Top achievements
Rank 1
answered on 14 Oct 2009, 10:31 PM
Thanks Princy, worked an like an absolute treat.  Saved me hours of work,
Tags
Grid
Asked by
Tony Deo
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Tony Deo
Top achievements
Rank 1
Share this question
or