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

[Solved] intercept push of a button

3 Answers 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fabio Craba
Top achievements
Rank 1
Fabio Craba asked on 12 Feb 2010, 11:59 AM

I added a GridButtonColumn at runtime
        RadGrid1.Columns.Clear()
        Dim objGC_Command As New Telerik.Web.UI.GridButtonColumn
        objGC_Command.ButtonType = Telerik.Web.UI.GridButtonColumnType.PushButton
        objGC_Command.CommandName = "Select"
        objGC_Command.UniqueName = "Select"
        objGC_Command.Text = "..."
        RadGrid1.Columns.Add(objGC_Command)

I handled the event triggered by pressing the button 
        Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs)
                If e.CommandName = "Select" Then
                        ...

                End If
        End Sub

The problem is that this event is not fired when I press the button because then HTML generated is

        <input type="submit" name="ctl00$CPHMain$RadGrid1$ctl00$ctl04$ctl00" value="..." />

why?

Thanks for your attention and sorry for my English

Fabio

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Feb 2010, 12:50 PM
Hi,

When you add a dynamic column to a declaratively created grid ,you need to add the columns first to the control collection and then set the property.This is important because no ViewState is managed for the object before it has been added to the corresponding collection.


Hope this helps. Do let me know if this was useful

Thanks,
Princy
0
Fabio Craba
Top achievements
Rank 1
answered on 12 Feb 2010, 03:23 PM
I tried as suggested but still does not work, when I press the button not generated the event  "RadGrid1_ItemCommand" but is reload the page.
I set
<% @ Page enableEventValidation = "false"
and
RadGrid1.EnableViewState = "true"

What else can I do?
0
Princy
Top achievements
Rank 2
answered on 17 Feb 2010, 06:11 AM
Hi,

Please  make sure that  you are using the AdvancedDataBinding Technique to bind your grid i.e. either using NeedDataSource or DataSource  control.


Thanks,
Princy
Tags
Grid
Asked by
Fabio Craba
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Fabio Craba
Top achievements
Rank 1
Share this question
or