1
This is how i return Datatable 
Then how to assign that datatable to list<> (is it possible to assign datatable to list<>) ??


 public DataTable Vehiclelist(string Vehicle)
        {
            SqlCommand newCmd = conn.CreateCommand();
            newCmd.Connection = conn;
            newCmd.CommandType = CommandType.Text;
            newCmd.CommandText = "SELECT * from  where  Vehicle_No ='" + Vehicle+ "'";

            SqlDataAdapter da = new SqlDataAdapter(newCmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            conn.Close();
            return dt;
    }

上記のコード セグメントは、テーブルからデータを読み取り、Datatable として返します。次に、このデータ テーブルをコード ビハインドで List<> に割り当てる方法を指示するか、データベースから List<> としてデータを読み取る方法を指示します。

4

3 に答える 3