Filling data at a particular location in a Data Table in C#

后端 未结 3 1956
故里飘歌
故里飘歌 2021-01-15 22:30

I am working with C# and Asp.Net. Is it possible to fill a particular location of a Data table.

I have a Data Table dt, and is contains this this k

3条回答
  •  别那么骄傲
    2021-01-15 23:24

    You can actually do this:

    1. Filter your table to the target row
    2. In the target row, write to the desired column

    Code example:

    Dim vRows() As DataRow
    vRows = dt.Select("DATA='Shop1'")
    vRows(0)("customer2") = "YourDataHere"
    

    This way you create an array of rows which is a reference to the DataTable, so you can directly edit the array.

    If you write this table to a database, don't forget to set up a DataAdapter and use the .Update method.

提交回复
热议问题