I have read through many of the questions related to my situation but I have not found one that does. I currently have a repeater with 4 bound items to it, clicking on a button in the repeater causes my error, below is the markup and codebehind. Can someone explain to me why this is happening and the fix for it? (I have excluded the page decleration and just included the page_load event. let me know if i should cut and past full code in)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="rptFoo" runat="server">
<ItemTemplate>
<asp:Button ID="btnfoo" runat="server" />
</ItemTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim items As New List(Of String)
items.Add("test1")
items.Add("test2")
items.Add("test3")
items.Add("test4")
rptFoo.DataSource = items
rptFoo.DataBind()
End Sub
"Invalid postback or callback argument" with Databound controls
answers my question incase anyone else needs this
That happens because the Repeater
is getting datasource (binding) as you perform the item
command operation. Just add if(not ispostback)
to the page_load
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With