It is not necessary to disable a gridEditCommandColumn in the prerender or databind event of the radgrid or datagrid.
To hide the GridEditCommandColumn:
wgdDetails.Columns.Item(1).Visible = False
To hide the CommandItem (Add)
wgdDetails.MasterTableView.IsItemInserted = False
wgdDetails.MasterTableView.CommandItemDisplay = Telerik.Web.UI.GridCommandItemDisplay.None
Showing posts with label RadGrid. Show all posts
Showing posts with label RadGrid. Show all posts
Friday, August 13, 2010
Thursday, June 3, 2010
Programatically changing the text of a GridButtonColum / GridEditCommandColumn / CommandItem
Task: Be able of programatically change the text of a Grid's GridButtonColum, GridEditCommandColumn and CommandItem.
Valid for: RadGrid and DataGrid
Process:
Firstly, identify the event. I've decided to use teh ItemDataBound, but it can be done using the PreRender as well.
Secondly, identify the Grid control and the columns id and types of what we need to modify.
Thirdly, do the programming in the chosen event. In this case ItemDatabound:
Finally, The code is ready to test.
Valid for: RadGrid and DataGrid
Process:
Firstly, identify the event. I've decided to use teh ItemDataBound, but it can be done using the PreRender as well.
Secondly, identify the Grid control and the columns id and types of what we need to modify.
Thirdly, do the programming in the chosen event. In this case ItemDatabound:
1 If (TypeOf e.Item Is GridHeaderItem) Then
2 Dim columnView As GridButtonColumn = CType(e.Item.OwnerTableView.GetColumn("View"), GridButtonColumn)
3 columnView.Text = GetCommonMessage(strGlobalUser, "View", strLang)
4 Dim columnEdit As GridEditCommandColumn = CType(e.Item.OwnerTableView.GetColumn("EditCommandColumn"), GridEditCommandColumn)
5 columnEdit.EditText = GetCommonMessage(strGlobalUser, "Edit", strLang)
6 End If
7
8
9 If e.Item.ItemType = GridItemType.CommandItem Then
10 CType(e.Item.FindControl("lblAddProduct"), Label).Text = GetCommonMessage(strGlobalUser, "AddNewLine", strLang)
11 CType(e.Item.FindControl("lnkAddProduct"), LinkButton).ToolTip = GetCommonMessage(strGlobalUser, "ClickHereToAddaNewLine", strLang)
12 End If
2 Dim columnView As GridButtonColumn = CType(e.Item.OwnerTableView.GetColumn("View"), GridButtonColumn)
3 columnView.Text = GetCommonMessage(strGlobalUser, "View", strLang)
4 Dim columnEdit As GridEditCommandColumn = CType(e.Item.OwnerTableView.GetColumn("EditCommandColumn"), GridEditCommandColumn)
5 columnEdit.EditText = GetCommonMessage(strGlobalUser, "Edit", strLang)
6 End If
7
8
9 If e.Item.ItemType = GridItemType.CommandItem Then
10 CType(e.Item.FindControl("lblAddProduct"), Label).Text = GetCommonMessage(strGlobalUser, "AddNewLine", strLang)
11 CType(e.Item.FindControl("lnkAddProduct"), LinkButton).ToolTip = GetCommonMessage(strGlobalUser, "ClickHereToAddaNewLine", strLang)
12 End If
Finally, The code is ready to test.
Labels:
CommandItem,
GridButtonColum,
GridEditCommandColumn,
RadGrid
Subscribe to:
Posts (Atom)