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

GridButtonColumn has no DataBind event

3 Answers 186 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aleksandar
Top achievements
Rank 1
Aleksandar asked on 13 Dec 2008, 12:56 PM

This is very unfortunate as CommandArgument is very convinient place for Eval("SomeDataField"). That way finding what was clicked would be very easy in ItemCommand and simmilar events (Delete, Insert...). Please consider this as nice feature for future implementations.
Regards,
Alex

PS
Finding what recordID is associated with ItemCommand is very dificult. This is what I do. Please correct if wrong:

        Select Case e.CommandName  
            Case "CheckDeleted"  
                Dim objItem As Telerik.Web.UI.GridDataItem = e.Item  
                Dim intRankID As Integer = _ 
                CInt(Regex.Match(Mid(objItem.KeyValues, _  
                objItem.KeyValues.LastIndexOf(":") + 3), "[0-9]{1,}").Value)  
                'The rest of the code goes here, now when I know  
                'what KeyValue was clicked on and caused postback (ItemCommand)  
            Case "InitInsert"  
                '....  
 
        End Select  
 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 15 Dec 2008, 07:19 AM
Hi Aleksandar,

I also tried the same and was not able to achieve the required scenario. But you can achieve the same using a GridTemplateColumn with a linkbutton in its ItemTemplate.

ASPX:
<telerik:GridTemplateColumn UniqueName="TempCol2" HeaderText="TempCol2" > 
                           <ItemTemplate> 
                               <asp:LinkButton  Text="Check" ID="LinkButton2" CommandArgument='<%#Eval("ProductID") %>' CommandName='<%#Eval("ProductName") %>' runat="server"></asp:LinkButton> 
                            </ItemTemplate> 
                  </telerik:GridTemplateColumn> 

Shinu
0
Aleksandar
Top achievements
Rank 1
answered on 15 Dec 2008, 10:27 AM
Thanks Shinu,
I know about that option as that is how I use it now. GridButtonColumn option would be much easier to implement and is in the spirit of RAD. ItemCommands (delete, insert, edit...) would be easyer to track as well.
Regards,
Alex
0
Sebastian
Telerik team
answered on 15 Dec 2008, 12:27 PM
Hi Aleksandar,

Unfortunately your request can not be fulfilled because the GridColumn is not a binding container as the GridDataItem/GridEditableItem respectively (the same is true for the MS GridView control), hence you are not able to use binding expressions as part of the GridColumn tag.

Therefore you may consider the workaround with the template column explained by Shinu in his post.

Kind regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Aleksandar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Aleksandar
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or