May
11
Written by:
Steve Gray
5/11/2011 11:13 AM
Here is a code sample to show the use of the ComponentArt ItemCommand event
- Protected Sub Grid1_ItemCommand(ByVal sender As Object, ByVal e As ComponentArt.Web.UI.GridItemCommandEventArgs) Handles Grid1.ItemCommand
- 'there are three ways to get data from the grid:
-
- '1: in the Command Argument
- Dim intUserID As Integer
- Dim LinkButton1 As New LinkButton
- 'get a reference to the control
- LinkButton1 = e.Control
- 'get the command argument
- intUserID = LinkButton1.CommandArgument
-
- '2 from a field in the grid
- Dim strSopnumber As String
- strSopnumber = e.Item("sopnumbe")
-
- '3 if the field is in a template, we have to search for it
- 'get a reference to the row number using the DataKeyField
- Dim intRowID As Int16
- intRowID = Me.Grid1.Items.IndexOf("rowid", e.Item("rowid"))
- 'We know this value, use a variable for readability
- Dim intColumn As Int16
- intColumn = 1
-
- Dim ddlNOCDMethod As DropDownList
- ddlNOCDMethod = CType(Me.Grid1.FindControl(intColumn, intRowID, "ddlNOCDMethod"), DropDownList)
-
- Dim lblSoptype As Label
- lblSoptype = CType(Me.Grid1.FindControl(intColumn, intRowID, "lblSoptpe"), Label)
- Dim intSoptype As Int16
- intSoptype = lblSoptype.Text
-
- End Sub
As always, I welcome your comments!