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

ItemCommand

2 Answers 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mansi A.
Top achievements
Rank 1
Mansi A. asked on 17 Dec 2013, 10:37 PM
Hi, 

  I have radgrid with GridButtonColumn that create text file for the clicked row, 
   Private Sub rgInvoices_ItemCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles rgInvoices.ItemCommand

       If Not e.CommandName = "CreateBill" Then
            Exit Sub
        End If
    'perform
end sub



  Looking to add a button outside the grid (Create All) so would loop through grid and one each iteration will call the CreateBill button 
    
    For Each item As GridDataItem In rgInvoices.MasterTableView.Items
        ''' How to call  rgInvoices_ItemCommand and execute button for this row?

    Next

   Thank You

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Dec 2013, 05:40 AM
Hi,

I guess you want to create some bill on the row button click and on an external button click. An easy way is to use a function that creates a text file, and call that function where necessary. If this doesn't help, please elaborate on your requirement.

ASPX:
<telerik:GridButtonColumn UniqueName="CreateBill" Text="Create Bill" CommandName="CreateBill">
</telerik:GridButtonColumn>
 . . . . . . . . .
<asp:Button ID="CreateAllBtn" runat="server" Text="Create All" OnClick="CreateAllBtn_Click" />

VB:
Protected Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs)
    If e.CommandName = "CreateBill" Then
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
            'Call function to create bill
        Dim id As String = item.GetDataKeyValue("ID").ToString()
    End If
End Sub
Protected Sub CreateAllBtn_Click(sender As Object, e As EventArgs)
    For Each item As GridDataItem In RadGrid1.MasterTableView.Items
            'Call function to create bill
        Dim id As String = item.GetDataKeyValue("ID").ToString()
    Next
End Sub

Thanks,
Shinu
0
Mansi A.
Top achievements
Rank 1
answered on 18 Dec 2013, 04:15 PM
that's was my work around. just thought there is a way to do that.

Thank You
Tags
Grid
Asked by
Mansi A.
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mansi A.
Top achievements
Rank 1
Share this question
or