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

adding text to a command button

5 Answers 454 Views
GridView
This is a migrated thread and some comments may be shown as answers.
andi
Top achievements
Rank 1
andi asked on 29 Jan 2008, 11:34 AM

hi,

how can i add text to a command button in a radgridview row?

        AddHandler RadGridDocuments.CommandCellClick, AddressOf RadGridDocuments_CommandCellClick
        Dim commandColumn As GridViewCommandColumn = New GridViewCommandColumn()
        commandColumn.HeaderText = "Command"
        commandColumn.Width = 100
        commandColumn.DataField = "PersonID"
        Me.RadGridDocuments.Columns.Add(commandColumn)

thanks, andreas

 

5 Answers, 1 is accepted

Sort by
0
andi
Top achievements
Rank 1
answered on 29 Jan 2008, 12:10 PM
...or is ist only possible to display the content of the .DataField property?

thanks, andreas
0
Jack
Telerik team
answered on 29 Jan 2008, 01:10 PM
Hello Andreas,

Yes, it is possible to display the content of a DataField inside the command button. You can do this in the CellFormatting event handler. Consider the following code snippet:

Private Sub radGridView1_CellFormatting(ByVal sender As ObjectByVal e As CellFormattingEventArgs) 
    Dim column As GridViewDataColumn = TryCast(e.CellElement.ColumnInfo, GridViewDataColumn) 
    If TypeOf e.CellElement.ColumnInfo Is GridViewCommandColumn AndAlso column.DataField = "Action" Then 
        Dim button As RadButtonElement = TryCast(e.CellElement.Children(0), RadButtonElement) 
        button.Text = column.DataField 
    End If 
End Sub 

Let us know if you have further questions.

Cheers,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Nicolaï
Top achievements
Rank 2
answered on 21 Feb 2011, 10:27 AM
DataField is not a member of Telerik.WinControls.UI.GridViewDataColumn ?!
0
Richard Slade
Top achievements
Rank 2
answered on 21 Feb 2011, 10:35 AM
Hello Nicolai,

The original answers in this thread are quite old now. For up to date information on the GridViewCommandColumn, please see the documentation on this column type that can be found here.

I hope you find this helpful but let me know if you need more information
Richard
0
Nicolaï
Top achievements
Rank 2
answered on 21 Feb 2011, 11:38 AM
Hello,

thanks Richard, found what I needed there!

Best regards,
Nicolaï
Tags
GridView
Asked by
andi
Top achievements
Rank 1
Answers by
andi
Top achievements
Rank 1
Jack
Telerik team
Nicolaï
Top achievements
Rank 2
Richard Slade
Top achievements
Rank 2
Share this question
or