首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET Framework >

System.ArgumentException: Item has already been added. Key in dictionary: 'Id'

2012-01-20 
System.ArgumentException: Item has already been added. Key in dictionary: IdKey being added: Id

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,换个名字吧

热点排行