当前位置: 代码迷 >> .NET Framework >> System.ArgumentException: Item has already been added. Key in dictionary: 'Id' Key being added: 'Id',该如何处理
  详细解决方案

System.ArgumentException: Item has already been added. Key in dictionary: 'Id' Key being added: 'Id',该如何处理

热度:333   发布时间:2016-05-02 00:51:33.0
System.ArgumentException: Item has already been added. Key in dictionary: 'Id' Key being added: 'Id'
public   partial   class   Send   :   System.Web.UI.Page
{
private   static   DataTable   addressDataTable;
protected   void   Page_Load(object   sender,   EventArgs   e)
  {
                if   (!IsPostBack)
                {  
                        if   (addressDataTable   ==   null)
                                curentAddressTable();
                        else
                                addressDataTable.Clear();
……

private   void   curentAddressTable()
        {
                addressDataTable   =   new   DataTable();
                addressDataTable.Clear();
                addressDataTable.Columns.Clear();
                addressDataTable.Columns.Add( "Id ");//System.ArgumentException:   Item   has   already   been   added.   Key   in   dictionary:   'Id '     Key   being   added:   'Id '
                addressDataTable.Columns.Add( "手机 ");
                addressDataTable.Columns.Add( "姓名 ");
        }


------解决方案--------------------
不要用Id作为column, table中有默认Id的column,换个名字吧
  相关解决方案