Assign Null value to the Integer Column in the DataTable

后端 未结 11 1313
旧巷少年郎
旧巷少年郎 2021-02-12 13:17

I have a datatable with One ColumnName \"CustomerID\" with Integer DataType. Dynamically I want to add rows to the DataTable. For that, I had created one DataRow object like:

11条回答
  •  遇见更好的自我
    2021-02-12 14:01

    Int32 Temp = 0;
    if !(Int32.TryParse(TextBox1.Text,Temp))
        DR["CustomerID"] = DBNull.Value
    else
        DR["CustomerID"] = Temp
    

提交回复
热议问题