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

ButtonColumn is NOT firing ItemCommand

3 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
TIM
Top achievements
Rank 1
TIM asked on 28 Oct 2011, 11:39 PM
I am creating the column structure programmatically as followers:


Dim dt as New DataTable
Dim clm_AddUser As New GridButtonColumn
Dim clm_DenyUser As New GridButtonColumn

dt.Columns.Add("clm_AddUser")
            dt.Columns.Add("clm_DenyUser")

clm_AddUser.DataTextField = "clm_AddUser"
            clm_DenyUser.DataTextField = "clm_DenyUser"

clm_AddUser.ButtonType = GridButtonColumnType.ImageButton
            clm_DenyUser.ButtonType = GridButtonColumnType.ImageButton

            clm_AddUser.ImageUrl = "~/images/AddUser.gif"
            clm_AddUser.CommandName = "AddUser"
            clm_AddUser.CommandArgument = "AddUser"


            clm_DenyUser.ImageUrl = "~/images/DenyUser.gif"
            clm_DenyUser.CommandName = "DenyUser"
            clm_DenyUser.CommandArgument = "DenyUser"

dt.Rows.Add("AddColumn", "DenyColumn")


now, in my ItemCommand section, I have:

    Private Sub grd_PendingLinks_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles grd_PendingLinks.ItemCommand
        If e.CommandName = "AddUser" Then lbl_pendinglinkreqs.Text = "ADD USER!"
        If e.CommandName = "DenyUser" Then lbl_pendinglinkreqs.Text = "DENY USER!"
    End Sub

this WILL get triggered if I turn off the ButtonType to Image, and leave it as default.

However, as soon as ButtonType is set to Image, the ItemCommand does NOT get triggered.

I have read of ways that I can do 'OnClick', but that requires setting a template in the .aspx file itself, and I am unsure of how to do that. So I am doing it programmatically.

Is this by design? Am I doing something wrong? Any info would be great.

3 Answers, 1 is accepted

Sort by
0
TIM
Top achievements
Rank 1
answered on 29 Oct 2011, 08:34 AM
Just did some tests,

both the hyperlink style, and the push button style fire the command, but the image style does not.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 29 Oct 2011, 09:48 AM
Hello,

are you creating all column programmatically or not ??

Thanks,
Jayesh Goyani
0
TIM
Top achievements
Rank 1
answered on 29 Oct 2011, 09:54 AM
Yes. I am creating it programmatkcally as per the code above.
Tags
Grid
Asked by
TIM
Top achievements
Rank 1
Answers by
TIM
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Share this question
or