Pass Parameter As DataGridItemEventArgs

R

rn5a

A Form has a DataGrid & a Button. The DataGrid's ItemDataBound event
calls a sub named 'BindData'. This sub first finds a Label which exists
in the ItemTemplate of the TemplateColumn of the DataGrid & does some
work with the Label.

Sub BindData(obj As Object, ea As DataGridItemEventArgs)
Dim lbl As Label

If (ea.Item.ItemType = ListItemType.Item Or ea.Item.ItemType =
ListItemType.AlternatingItem) Then
lbl = ea.Item.FindControl("lblAcre")
.....
.....
End If
End Sub

The Button has the Click event which invokes a sub named 'SubmitPage'.

Sub SubmitPage(obj As Object, ea As EventArgs)
.....
End Sub

Now I did like the 'SubmitPage' sub to invoke the 'BindData' sub. How
do I accomplish this? In other words, what parameters do I pass from
the 'SubmitPage' sub to the 'BindData' sub which the latter expects?
 
T

Teemu Keiski

You can't get DataGridItemEventArgs in SubmitPage (it is event argument data
type specific to a event, so it's not even wise to use as input to a
method), but you can loop through the DataGrid manually.

Sub SubmitPage(obj As Object, ea As EventArgs)


For each dgitem As DataGridItem in DataGrid1.Items

Dim lbl As Label=Nothing

If (dgitem.ItemType = ListItemType.Item Or dgitem.ItemType =
ListItemType.AlternatingItem) Then
lbl = dgitem.FindControl("lblAcre")
'Do something with the Label
End If

Next

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

OnItemCommand & OnItemDataBound 2
DataGrid OnDeleteCommand 0
DataRow 1
DropDownList DataGrid 1
ItemCreated V/s. ItemDataBound 3
JavaScript confirm 2
DataBind 1
OnPreRender 0

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top