How to add New Column with Value to the Existing DataTable?

后端 未结 3 1046
轻奢々
轻奢々 2020-12-23 15:41

I have One DataTable with 5 Columns and 10 Rows. Now I want to add one New Column to the DataTable and I want to assign DropDownList value to the New Column. So th

3条回答
  •  被撕碎了的回忆
    2020-12-23 16:38

    Without For loop:

    Dim newColumn As New Data.DataColumn("Foo", GetType(System.String))     
    newColumn.DefaultValue = "Your DropDownList value" 
    table.Columns.Add(newColumn) 
    

    C#:

    System.Data.DataColumn newColumn = new System.Data.DataColumn("Foo", typeof(System.String));
    newColumn.DefaultValue = "Your DropDownList value";
    table.Columns.Add(newColumn);
    

提交回复
热议问题