This message was discovered on ASPFriends.com 'aspngvb' list.
| =?iso-8859-1?Q?Andr=E9_Colbi=F6rnsen?= |
Your button can not refer to 'DataGridEventArgs':
Public Sub sub_Buy(sender As Object, e As System.Web.UI.WebControls.DataGridItemEventArgs) <-- Problem here
Should be 'EventArgs':
Public Sub sub_Buy(sender As Object, e As System.Web.UI.WebControls.EventArgs)
Hth
Regards/Halsningar
Andre Colbiornsen -------------------------------------- Sonnenburg Communications Bergsgatan 3, SE-211 54 Malm=F6 Sweden Tel.: +46-(0)40-97 78 80 Fax.: +46-(0)40-97 78 80 Mob.: +46-(0)708-97 78 79 Mail: Click here to reveal e-mail address Web.: www.sonnenburg.se ---------------------------------------- B2B Web Solutions - Specializing in .Net ----------------------------------------
-----Ursprungligt meddelande----- Fr=E5n: Administrator [mailto:Click here to reveal e-mail address]=20 Skickat: den 26 juli 2002 15:48 Till: aspngvb =C4mne: [aspngvb] RE: CType
Hello Darren,
I try what you have below but I get the following error:
Compiler Error Message: BC30408: Method 'Public Sub sub_Buy(sender As Object, e As System.Web.UI.WebControls.DataGridItemEventArgs)' does not have the same signature as delegate 'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)'.
Line 45: </table> Line 46: </ItemTemplate> Line 47: <FooterTemplate><Asp:Button ID=3D"btnPurchase" Text=3D"Purchase = Addesses" OnClick=3D"sub_Buy" Runat=3D"server" /> Line 48: </FooterTemplate> Line 49: </ASP:TemplateColumn>
Here is the exact datagrid:
<form id=3D"Form1" method=3D"post" runat=3D"server"> <asp:DataGrid ShowFooter=3D"True" CellPadding=3D"2" CellSpacing=3D"2" ID=3D"dgCart" DataKeyField=3D"ShoppingCartID" ShowHeader=3D"True" AlternatingItemStyle-BackColor=3D"LemonChiffon" AutoGenerateColumns=3D"False" Runat=3D"server" HeaderStyle-BackColor=3D"LemonChiffon"> <Columns> <Asp:TemplateColumn HeaderStyle-BorderWidth=3D"0" ItemStyle-BorderWidth=3D"0" FooterStyle-BorderWidth=3D"0"> <ItemTemplate> <Asp:CheckBox ID=3D"chkTest" Checked=3D"True" Runat=3D"server" /> <input type=3D"hidden" id=3D"WID" value=3D"<%# Container.DataItem("WomanID")%>"> </ItemTemplate> <FooterTemplate><asp:Button ID=3D"btnDelete" Text=3D"Remove" Runat=3D"server" = onclick=3D"sub_DeleteCartItem" /> </FooterTemplate> </Asp:TemplateColumn> <Asp:TemplateColumn HeaderStyle-BorderWidth=3D"0" ItemStyle-BorderWidth=3D"0" FooterStyle-BorderWidth=3D"0"> <HeaderTemplate> Picture </HeaderTemplate> <ItemTemplate> <a href=3D"profile.aspx?UID=3D<%# Container.DataItem("WomanID")%>" target=3D"main"><img src=3D"thumb.aspx?id=3D<%# Container.DataItem("MainImage")%>" Height=3D"50" border=3D"0"></a> </ItemTemplate> </ASP:TemplateColumn> <Asp:TemplateColumn HeaderStyle-BorderWidth=3D"0" ItemStyle-BorderWidth=3D"0" FooterStyle-BorderWidth=3D"0"> <HeaderTemplate> Contact </HeaderTemplate> <ItemTemplate> <table align=3Dleft class=3Dnoborder> <tr> <td><%# Container.DataItem("CustomerFirstName")%></td><td><%# Container.DataItem("City")%>, <%# Container.DataItem("Country")%></td> </tr> </table> </ItemTemplate> <FooterTemplate><Asp:Button ID=3D"btnPurchase" Text=3D"Purchase Addesses" OnClick=3D"sub_Buy" Runat=3D"server" /> </FooterTemplate> </ASP:TemplateColumn> </Columns> </Asp:DataGrid> </form>
And the exact function:
Sub sub_Buy(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Dim i As Integer =3D 0 Dim cb As CheckBox Dim dgi As DataGridItem Dim chk As String Dim chkString As String Dim htmlInput As HtmlInputHidden Dim str As String For Each dgi In dgCart.Items chkTest =3D e.Item.Cells(0).Controls(0) If chkTest.Checked Then htmlInput =3D e.Item.Cells(0).Controls(1) str =3D htmlInput.Value chk +=3D (i + 1) & "=3D" & str & "&" End If i +=3D 1 Next chkString =3D "?num=3D" & i & "&" & chk Server.Transfer("buy.aspx" & chkString) End Sub
I have tried all of the other methods suggested, and I can't figure out the problem. =20
Thanks,
John
-----Original Message----- From: Darren Neimke [mailto:Click here to reveal e-mail address] Sent: Thursday, July 25, 2002 9:35 PM To: aspngvb Subject: [aspngvb] RE: CType
Actually, let me explain further (because my example is still wrong!!)
You had:
Dim dgi As DataGridItem CType(dgi.Cells(0).Controls(2), HTMLInputHidden).ToString
So you are grabbing the Control at Controls(2) - of dgi (is dgi an *instance* of a DataGrid at this point in time?) - , Casting it to HTMLInputHidden, then calling ToString() against that *object*.
Basically, you want to use the Cast to grab an *instance* of the actual HTMLInputHidden object, then use it's properties in the usual manner.
Let's presume that we are attempting to access that control from within the OnItem event handler of a DataGrid...
Protected Sub ItemCommand(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
End Sub
>From within that handler, you can use *casting* to access a specific DataGridItem...
=09 Dim dgi As DataGridItem dgi =3D CType(e.Item, DataGridItem)
Then you can access the members of that DataGridItem by making calls against your instance:
Dim ctl As Control
For Each ctl In dgi.Cells(0).Controls ... Next
Of course, in your case, if you know exactly where to look you can go directly to it using the appropriate Cast:
Dim htmlInput As HtmlInputHidden htmlInput =3D CType(e.Item.Cells(0).Controls(2), HtmlInputHidden)
Then, rather than calling ToString() against the *object*, you call it against the *property* that you are accessing:
Dim str As String =3D htmlInput.Value
| [aspngvb] member Click here to reveal e-mail address =3D YOUR ID=20 | http://www.asplists.com/asplists/aspngvb.asp =3D JOIN/QUIT
| [aspngvb] member Click here to reveal e-mail address =3D YOUR ID=20 | http://www.asplists.com/asplists/aspngvb.asp =3D JOIN/QUIT
|
|
| |
| |
| Administrator |
Andre,
Unfortunately when I use the "e as System.EventArgs" the 'e.items' is = not a member of system.eventargs. And I need the 'e.items' to find the = value of the HTMLInputHidden in the datagrid.
Thanks for the though though.
John=20
-----Original Message----- From: Andr=E9 Colbi=F6rnsen [mailto:Click here to reveal e-mail address] Sent: Friday, July 26, 2002 10:17 AM To: aspngvb Subject: [aspngvb] SV: RE: CType
Your button can not refer to 'DataGridEventArgs':
Public Sub sub_Buy(sender As Object, e As System.Web.UI.WebControls.DataGridItemEventArgs) <-- Problem here
Should be 'EventArgs':
Public Sub sub_Buy(sender As Object, e As System.Web.UI.WebControls.EventArgs)
Hth
Regards/Halsningar
Andre Colbiornsen -------------------------------------- Sonnenburg Communications Bergsgatan 3, SE-211 54 Malm=F6 Sweden Tel.: +46-(0)40-97 78 80 Fax.: +46-(0)40-97 78 80 Mob.: +46-(0)708-97 78 79 Mail: Click here to reveal e-mail address Web.: www.sonnenburg.se ---------------------------------------- B2B Web Solutions - Specializing in .Net ----------------------------------------
-----Ursprungligt meddelande----- Fr=E5n: Administrator [mailto:Click here to reveal e-mail address]=20 Skickat: den 26 juli 2002 15:48 Till: aspngvb =C4mne: [aspngvb] RE: CType
Hello Darren,
I try what you have below but I get the following error:
Compiler Error Message: BC30408: Method 'Public Sub sub_Buy(sender As Object, e As System.Web.UI.WebControls.DataGridItemEventArgs)' does not have the same signature as delegate 'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)'.
Line 45: </table> Line 46: </ItemTemplate> Line 47: <FooterTemplate><Asp:Button ID=3D"btnPurchase" Text=3D"Purchase = Addesses" OnClick=3D"sub_Buy" Runat=3D"server" /> Line 48: </FooterTemplate> Line 49: </ASP:TemplateColumn>
Here is the exact datagrid:
<form id=3D"Form1" method=3D"post" runat=3D"server"> <asp:DataGrid ShowFooter=3D"True" CellPadding=3D"2" CellSpacing=3D"2" ID=3D"dgCart" DataKeyField=3D"ShoppingCartID" ShowHeader=3D"True" AlternatingItemStyle-BackColor=3D"LemonChiffon" AutoGenerateColumns=3D"False" Runat=3D"server" HeaderStyle-BackColor=3D"LemonChiffon"> <Columns> <Asp:TemplateColumn HeaderStyle-BorderWidth=3D"0" ItemStyle-BorderWidth=3D"0" FooterStyle-BorderWidth=3D"0"> <ItemTemplate> <Asp:CheckBox ID=3D"chkTest" Checked=3D"True" Runat=3D"server" /> <input type=3D"hidden" id=3D"WID" value=3D"<%# Container.DataItem("WomanID")%>"> </ItemTemplate> <FooterTemplate><asp:Button ID=3D"btnDelete" Text=3D"Remove" Runat=3D"server" = onclick=3D"sub_DeleteCartItem" /> </FooterTemplate> </Asp:TemplateColumn> <Asp:TemplateColumn HeaderStyle-BorderWidth=3D"0" ItemStyle-BorderWidth=3D"0" FooterStyle-BorderWidth=3D"0"> <HeaderTemplate> Picture </HeaderTemplate> <ItemTemplate> <a href=3D"profile.aspx?UID=3D<%# Container.DataItem("WomanID")%>" target=3D"main"><img src=3D"thumb.aspx?id=3D<%# Container.DataItem("MainImage")%>" Height=3D"50" border=3D"0"></a> </ItemTemplate> </ASP:TemplateColumn> <Asp:TemplateColumn HeaderStyle-BorderWidth=3D"0" ItemStyle-BorderWidth=3D"0" FooterStyle-BorderWidth=3D"0"> <HeaderTemplate> Contact </HeaderTemplate> <ItemTemplate> <table align=3Dleft class=3Dnoborder> <tr> <td><%# Container.DataItem("CustomerFirstName")%></td><td><%# Container.DataItem("City")%>, <%# Container.DataItem("Country")%></td> </tr> </table> </ItemTemplate> <FooterTemplate><Asp:Button ID=3D"btnPurchase" Text=3D"Purchase Addesses" OnClick=3D"sub_Buy" Runat=3D"server" /> </FooterTemplate> </ASP:TemplateColumn> </Columns> </Asp:DataGrid> </form>
And the exact function:
Sub sub_Buy(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Dim i As Integer =3D 0 Dim cb As CheckBox Dim dgi As DataGridItem Dim chk As String Dim chkString As String Dim htmlInput As HtmlInputHidden Dim str As String For Each dgi In dgCart.Items chkTest =3D e.Item.Cells(0).Controls(0) If chkTest.Checked Then htmlInput =3D e.Item.Cells(0).Controls(1) str =3D htmlInput.Value chk +=3D (i + 1) & "=3D" & str & "&" End If i +=3D 1 Next chkString =3D "?num=3D" & i & "&" & chk Server.Transfer("buy.aspx" & chkString) End Sub
I have tried all of the other methods suggested, and I can't figure out the problem. =20
Thanks,
John
-----Original Message----- From: Darren Neimke [mailto:Click here to reveal e-mail address] Sent: Thursday, July 25, 2002 9:35 PM To: aspngvb Subject: [aspngvb] RE: CType
Actually, let me explain further (because my example is still wrong!!)
You had:
Dim dgi As DataGridItem CType(dgi.Cells(0).Controls(2), HTMLInputHidden).ToString
So you are grabbing the Control at Controls(2) - of dgi (is dgi an *instance* of a DataGrid at this point in time?) - , Casting it to HTMLInputHidden, then calling ToString() against that *object*.
Basically, you want to use the Cast to grab an *instance* of the actual HTMLInputHidden object, then use it's properties in the usual manner.
Let's presume that we are attempting to access that control from within the OnItem event handler of a DataGrid...
Protected Sub ItemCommand(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
End Sub
>From within that handler, you can use *casting* to access a specific DataGridItem...
=09 Dim dgi As DataGridItem dgi =3D CType(e.Item, DataGridItem)
Then you can access the members of that DataGridItem by making calls against your instance:
Dim ctl As Control
For Each ctl In dgi.Cells(0).Controls ... Next
Of course, in your case, if you know exactly where to look you can go directly to it using the appropriate Cast:
Dim htmlInput As HtmlInputHidden htmlInput =3D CType(e.Item.Cells(0).Controls(2), HtmlInputHidden)
Then, rather than calling ToString() against the *object*, you call it against the *property* that you are accessing:
Dim str As String =3D htmlInput.Value
| [aspngvb] member Click here to reveal e-mail address =3D YOUR ID=20 | http://www.asplists.com/asplists/aspngvb.asp =3D JOIN/QUIT
| [aspngvb] member Click here to reveal e-mail address =3D YOUR ID=20 | http://www.asplists.com/asplists/aspngvb.asp =3D JOIN/QUIT
| [aspngvb] member Click here to reveal e-mail address =3D YOUR ID | http://www.asplists.com/asplists/aspngvb.asp =3D JOIN/QUIT
|
|
| |
|
|
|
|
|