Charles Baldo
asked on
Repeater Command Not being executed
Hello,
I have a repeater with a button
<asp:Repeater id=GalleryRepeater OnItemCommand="GalleryRepe ater_ItemC ommand" runat="server">
<ItemTemplate>
<asp:Button id="btnGallery" OnCommand="GalleryClicked" Text='<%# DataBinder.Eval(Container. DataItem, "Gallery")%>' CommandName="Display" CommandArgument='<%# DataBinder.Eval(Container. DataItem, "Gallery")%>' runat="server"></asp:Butto n>
</ItemTemplate>
</asp:Repeater>
The Button seems to be woring ok. The Text, CommandName, and CommandArgument are binded nicely with data
The problem is the buttons evenet never seems to fire
CodeBehind
Protected WithEvents GalleryRepeater As System.Web.UI.WebControls. Repeater
Protected WithEvents btnGallery As System.Web.UI.WebControls. Button
Public Sub GalleryRepeater_ItemComman d(ByVal sender As Object, ByVal e As RepeaterCommandEventArgs) Handles GalleryRepeater.ItemComman d
Response.Redirect("http://www.globalwindows.com")
Response.Write(e.CommandAr gument)
Response.Write(e.CommandNa me)
Response.Write(e.CommandSo urce)
End Sub
When the button is clicked the subroutine never seems to be called. I got this same code to work in an inline version of the code. I did a lot of cutting and pasting but think I got it right.
Any help is apprecited
Best
Chuck
I have a repeater with a button
<asp:Repeater id=GalleryRepeater OnItemCommand="GalleryRepe
<ItemTemplate>
<asp:Button id="btnGallery" OnCommand="GalleryClicked"
</ItemTemplate>
</asp:Repeater>
The Button seems to be woring ok. The Text, CommandName, and CommandArgument are binded nicely with data
The problem is the buttons evenet never seems to fire
CodeBehind
Protected WithEvents GalleryRepeater As System.Web.UI.WebControls.
Protected WithEvents btnGallery As System.Web.UI.WebControls.
Public Sub GalleryRepeater_ItemComman
Response.Redirect("http://www.globalwindows.com")
Response.Write(e.CommandAr
Response.Write(e.CommandNa
Response.Write(e.CommandSo
End Sub
When the button is clicked the subroutine never seems to be called. I got this same code to work in an inline version of the code. I did a lot of cutting and pasting but think I got it right.
Any help is apprecited
Best
Chuck
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Where should I add the code
AddHandler button.Click, AddressOf Me.Button_Clicked
in the Page_Load??
Thank You
chuck
AddHandler button.Click, AddressOf Me.Button_Clicked
in the Page_Load??
Thank You
chuck
if you want to add this handler you have to create itemdatabound event and there
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.Alternating Then
Dim btn as Button = CType(e.Item.FIndControl(" btnGallery "), Button )
AddHandler btn.Click, AddressOf Me.Button_Clicked
End If
but you can not access direct the btnGallery because it is nested control
B..M
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.Alternating Then
Dim btn as Button = CType(e.Item.FIndControl("
AddHandler btn.Click, AddressOf Me.Button_Clicked
End If
but you can not access direct the btnGallery because it is nested control
B..M
when you put in the tag ( like in the code OnItemCommand="GalleryRepe
AddHandler GalleryRepeater.ItemComman
B..M