How do I access the "lbl_TotalSeconds" label in a vb sub to change its text
3 Answers, 1 is accepted
answered on 07 Nov 2018, 05:19 PM
Accessing controls can be done using different events (Load, ItemCreated, ItemDataBound, PreRender, etc..), hence you will need the choose the one that best fits your requirements. Here is one example of accessing the label inside the Footer item using the PreRender event of RadGrid.
Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As EventArgs)
Dim footer As GridFooterItem = TryCast(RadGrid1.MasterTableView.GetItems(GridItemType.Footer)(0), GridFooterItem)
Dim lbl As Label = TryCast(footer.FindControl("lbl_TotalSeconds"), Label)
I can't seem to figure out how to do this in the RadGrid1_NeedDataSource sub though. It seems that MasterTableView doesn't have any items at this sub. Can you help me with it?
answered on 09 Nov 2018, 04:48 PM
The NeedDataSource event is part of the Advanced data binding of the RadGrid control. In the event handler, the data is retrieved either from a service or created in the code-behind and is set to the DataSource of the grid. Afterward, use the DataField property to specify the data field that should be used for the specific column.
Check out the following article which puts more insight on the matter: