Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
I can not add a new item in a drop down list
Message
From
21/09/2011 14:29:03
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
I can not add a new item in a drop down list
Environment versions
Environment:
C# 4.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01524188
Message ID:
01524188
Views:
81
I am developing this exercise

http://www.codeproject.com/KB/aspnet/LinqDataSource2.aspx

The part 1 and 2 runs good, but int eh 3rd part of the exercise i can not add a new item, it appears "All" thte end of the list i would prefer in the beginning of the list) but when i pcik "All" it appears a error mesage "server appliaction error "/" ", adn says "the string odes not have the correct format". how can i solve it?
P.D. to add "ALL" at the begining of the list does not worked as i thought that is why it is now in comments
Thank you in advance

Here is the code
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
 
namespace lmproyectolinq 
{ 
    public partial class _Default : System.Web.UI.Page 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            if (!Page.IsPostBack) 
            { 
                //FillList(); 
                using (ProductosDataContext context = new ProductosDataContext()) 
                { 
                    //LINQ Query 
                    var query = from ct in context.Productos 
                                select ct.IdCategoría; 
                    if (query != null) 
                    { 
                         
                        DropDownList1.DataSource = query.Distinct().ToList(); 
                        DropDownList1.DataBind(); 
                        FillList(); 
                    } 
                } 
                 
            } 
        } 
 
        protected void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e) 
        { 
            Response.Write("<br/> "); 
            if (DropDownList1.SelectedValue == "All") 
            { 
                e.WhereParameters.Remove("idCategoría"); 
            } 
        } 
 
 
 
        protected void FillList() 
        { 
            DropDownList1.Items.Add(new ListItem("All", "All")); 
        } 
    } 
}
Reply
Map
View

Click here to load this message in the networking platform