求一个 格式化的问题
我创建了一个datatable列
DataTable dt = new DataTable( "Temp ");
DataColumn myDataColumn;
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType( "System.Int32 ");
myDataColumn.ColumnName = "USERID ";
myDataColumn.ReadOnly = true;
myDataColumn.AllowDBNull = false;
myDataColumn.Unique = true;
myDataColumn.AutoIncrement = true;
myDataColumn.AutoIncrementSeed = 1000;
myDataColumn.AutoIncrementStep = 10;
dt.Columns.Add(myDataColumn);
可是我在创建行的时候
//创建行
DataRow newRow;
newRow = dt.NewRow();
newRow[ "USERID "]= strPerCD; strPerCD为0003
在 newRow[ "USERID "]中 变成了3
请问一下怎么才能显示0003呢???
------解决方案--------------------dt.Columns.Add(new DataColumn( "USERID ", typeof(string))); 字符类型的行么?
------解决方案-------------------- myDataColumn.DataType = Type.GetType( "System.String ");
...............
newRow[ "USERID "]= strPerCD.ToString();
------解决方案--------------------myDataColumn.AutoIncrement = true;
应该是 自增列造成的改成false就可以
自增列似乎只能是整型