Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Pass Parameter As DataGridItemEventArgs

Reply
Thread Tools

Pass Parameter As DataGridItemEventArgs

 
 
rn5a@rediffmail.com
Guest
Posts: n/a
 
      12-02-2006
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?

 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      12-02-2006
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


--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>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?
>



 
Reply With Quote
 
 
 
 
rn5a@rediffmail.com
Guest
Posts: n/a
 
      12-02-2006
Thanks, Teemu....that's exactly what I was looking out for


Teemu Keiski wrote:
> 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
>
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
> >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?
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pass a parameter for a function parameter in a function AzamSharp Javascript 2 07-05-2008 12:24 AM
Parameter List / Parameter Block / Anything patterns... mast2as@yahoo.com C++ 4 03-29-2007 09:37 PM
DataGridItemEventArgs and Hyperlinkcolumn =?Utf-8?B?UGF1bA==?= ASP .Net 1 08-15-2006 09:29 PM
DataGridItemEventArgs dataitem decimal value rounding =?Utf-8?B?U3Vl?= ASP .Net 2 06-26-2006 03:28 PM
DataGridItemEventArgs.Item.Cells - How to find last cell? Hajime Kusakabe ASP .Net 1 10-23-2003 10:28 PM



Advertisments