Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1502: The best overloaded method match for 'DevExpress.Web.ASPxEditors.ListEditItemCollection.Remove(DevExpress.Web.ASPxEditors.ListEditItem)' has some invalid arguments

Source Error:

C#
Line 35:     protected void ASPxButton2_Click(object sender, EventArgs e)
Line 36:     {
Line 37:         ASPxListBox1.Items.Remove(ASPxTextBox1.Text);
Line 38:     }
Line 39: }



Source File: c:\Documents and Settings\azhar\My Documents\Visual Studio 2010\WebSites\WebSite7\listboxinsert,delete.aspx.cs Line: 37





code..........

C#
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;
using System.Text;
using System.Collections;
using DevExpress.Web.ASPxEditors;


public partial class listboxinsert_delete : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
   
    protected void ASPxButton1_Click(object sender, EventArgs e)
    {
        ASPxListBox1.Items.Add(ASPxTextBox1.Text);
        ASPxTextBox1.Text = "";
    }
    protected void ASPxButton2_Click(object sender, EventArgs e)
    {
        ASPxListBox1.Items.Remove(ASPxTextBox1.Text);
    }
}
Posted
Updated 12-Feb-12 20:35pm
v3
Comments
Al Moje 13-Feb-12 2:32am    
Edit and add pre tag.
rockpune 13-Feb-12 2:39am    
sorry sir am newly learning .net where and how to add pre tag pleas tell me.........
lukeer 13-Feb-12 3:13am    
The pre tags are not for your C# coding, but for its proper representation here in the forum.

You enclose your code this way:
<pre lang="c#">TypeInYourCodeHere();<pre>
Then the forum displays it in a coding-style font and with nicely coloured key words.

And there is a checkbox "Treat my content as plain text, not as HTML" at the bottom of the edit field. Make shure it is unchecked for the format to take effect.

The parameter type expected is DevExpress.Web.ASPxEditors.ListEditItem but you are trying to use ASPxTextBox1.Text which is of the type System.String.

—SA
 
Share this answer
 
Comments
Tech Code Freak 13-Feb-12 3:18am    
5up!
Sergey Alexandrovich Kryukov 13-Feb-12 3:21am    
Thank you, Tech Code Freak.
--SA
try

C#
ASPxListBox1.Items.Remove(new ListEditItem(ASPxTextBox1.Text));


or

C#
ASPxListBox1.Items.Remove(FindByText(ASPxTextBox1.Text));
 
Share this answer
 
Comments
rockpune 13-Feb-12 2:49am    
i will try sir but getting this type of error


Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Source Error:

Line 26: protected void ASPxButton2_Click(object sender, EventArgs e)
Line 27: {
Line 28: ASPxListBox1.Items.Remove(new ListEditItem(ASPxTextBox1.Text));
Line 29: //ASPxTextBox1.Text = "";
Line 30: }
Hi,

I am could not imagine what the purpose of your code…

I fixed the error as mention above...
C#
 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//using DevExpress.Web.ASPxEditors;  - This line cause error. Why using this?
//public partial class listboxinsert_delete : System.Web.UI.Page  - This line cause error
public partial class listboxinsert : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    { 
    }
   
    protected void ASPxButton1_Click(object sender, EventArgs e)
    {
        ASPxListBox1.Items.Add(ASPxTextBox1.Text);
        ASPxTextBox1.Text = "";
    }
    protected void ASPxButton2_Click(object sender, EventArgs e)
    {
        ASPxListBox1.Items.Remove(ASPxTextBox1.Text);
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900