0

I have this code in my aspx page :

<asp:DropDownList ID="campagnes" runat="server" AutoPostBack="True"  ></asp:DropDownList>

I am filling the DropDownList with :

foreach (DataRow DR in DS.Tables["CAMPAGNES"].Rows) {
     campagnes.Items.Add(new ListItem(DR.Field<string>("LIBELLE").ToString(), DR.Field<int>("STATUSGROUP")));
}

The DropDownList is filled with the data i wanted to add but if i select an item in the list, i get this error :

"Invalid postback or callback argument ..."

I have no idea what does it mean and how to correct it.

Stan
  • 391
  • 2
  • 5
  • 21

1 Answers1

0

I'm fairly new myself to C#, but I normally find most postback errors can be solved by wrapping your call to your populate drop-down list method with.

  protected void Page_Load(object sender, EventArgs e){

     if (!Page.IsPostBack)
     { 
      //your dropdown list code
     }
  }

Failing that my next attempt would be to put your dropdown in an update panel to avoid a postback all together.

see here

Verno
  • 428
  • 1
  • 5
  • 20
  • I was already wrapping it with "!IsPostBack" but i still had the error. I have seen that update panel might be a solution but i haven't used it yet. I will look into it. Thanks. – Stan Nov 30 '15 at 14:44
  • 1
    have your tried to disable event validation to see if that's what's causing the problem? (EnableEventValidation="false") I definitely wouldn't leave it off, but you would know that was the problem, this question might help [link](http://stackoverflow.com/questions/7476329/asp-net-invalid-postback-or-callback-argument) – Verno Nov 30 '15 at 14:57
  • Again, thank you for your help. Using "update panel" is solving the problem. – Stan Nov 30 '15 at 15:32